-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44b7508
commit 5611004
Showing
10 changed files
with
307 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use an official Java runtime as a parent image | ||
FROM openjdk:17-jdk-alpine | ||
|
||
# Create user to run the app as (instead of root) | ||
RUN addgroup -S app && adduser -S app -G app | ||
|
||
# User user "app" | ||
USER app | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the JAR file into the container | ||
COPY build/libs/ReverseProxy-0.0.1-SNAPSHOT.jar /app/app.jar | ||
|
||
# Set the command to run the JAR file | ||
ENTRYPOINT ["java", "-jar", "/app/app.jar"] | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.springframework.boot") version "3.3.2" | ||
id("io.spring.dependency-management") version "1.1.6" | ||
kotlin("jvm") version "1.9.24" | ||
kotlin("plugin.spring") version "1.9.24" | ||
application | ||
} | ||
|
||
application { | ||
mainClass.set("com.example.reverseproxy.ReverseProxyApplicationKt") | ||
} | ||
|
||
group = "com.example" | ||
version = "0.0.1-SNAPSHOT" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom(configurations.annotationProcessor.get()) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
extra["springCloudVersion"] = "2023.0.3" | ||
|
||
dependencies { | ||
/* kotlin co-routines */ | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") | ||
|
||
/* kotlin reflection */ | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
|
||
/* spring web */ | ||
implementation("org.springframework.boot:spring-boot-autoconfigure") | ||
|
||
/* spring cloud gateway */ | ||
implementation("org.springframework.cloud:spring-cloud-starter-gateway") | ||
implementation("org.springframework.boot:spring-boot-starter-actuator") | ||
|
||
/* test - dependencies */ | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") | ||
|
||
// testImplementation("io.projectreactor:reactor-test") | ||
// testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
// implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") | ||
implementation(kotlin("stdlib-jdk8")) | ||
|
||
} | ||
|
||
dependencyManagement { | ||
imports { | ||
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}") | ||
} | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs += "-Xjsr305=strict" | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
|
||
tasks.withType<Test> { | ||
enabled = false | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.withType<Jar> { | ||
|
||
// specify JAR file name | ||
archiveBaseName.set("ReverseProxy") | ||
archiveVersion.set("0.0.1-SNAPSHOT") | ||
|
||
// ensure that both compiled classes and resources are included in the JAR file | ||
from(sourceSets.main.get().output) | ||
sourceSets.main.configure { | ||
resources.srcDirs("src/main/").includes.addAll(arrayOf("**/*.*")) | ||
} | ||
|
||
// include dependencies in the JAR file | ||
dependsOn(configurations.runtimeClasspath) | ||
from({ | ||
configurations.runtimeClasspath.get() | ||
.filter { it.name.endsWith("jar") } | ||
.map { zipTree(it) } | ||
}) | ||
|
||
// specify location of main class | ||
manifest { | ||
attributes["Main-Class"] = "com.example.reverseproxy.ReverseProxyApplicationKt" | ||
} | ||
|
||
// define duplicate strategy | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
|
||
// exclude specific signed files from being included in the final JAR | ||
exclude("META-INF/*.SF") | ||
exclude("META-INF/*.DSA") | ||
exclude("META-INF/*.RSA") | ||
} | ||
|
||
tasks.named<ProcessResources>("processResources") { | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} | ||
|
||
tasks.named("bootJar") { | ||
dependsOn("jar") | ||
} | ||
tasks.named("bootJar") { | ||
mustRunAfter("jar") | ||
} | ||
tasks.named("bootDistZip") { | ||
dependsOn("jar") | ||
} | ||
tasks.named("bootDistZip") { | ||
mustRunAfter("jar") | ||
} | ||
tasks.named("bootDistTar") { | ||
dependsOn("jar") | ||
} | ||
tasks.named("bootDistTar") { | ||
mustRunAfter("jar") | ||
} | ||
tasks.named("startScripts") { | ||
dependsOn("bootJar") | ||
} | ||
tasks.named("startScripts") { | ||
mustRunAfter("bootJar") | ||
} |
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
Spring BFF/ReverseProxy/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "ReverseProxy" |
12 changes: 12 additions & 0 deletions
12
Spring BFF/ReverseProxy/src/main/kotlin/com/example/reverseproxy/ReverseProxyApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.reverseproxy | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class ReverseProxyApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<ReverseProxyApplication>(*args) | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
Spring BFF/ReverseProxy/src/main/resources/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: com.example.reverseproxy.ReverseProxyApplicationKt | ||
|
2 changes: 2 additions & 0 deletions
2
Spring BFF/ReverseProxy/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# spring application name | ||
spring.application.name=ReverseProxy |
123 changes: 123 additions & 0 deletions
123
Spring BFF/ReverseProxy/src/main/resources/application.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Custom properties to ease configuration overrides | ||
# on command-line or IDE launch configurations | ||
# more here: | ||
# https://github.com/eugenp/tutorials/blob/master/spring-security-modules/spring-security-oauth2-bff/backend/reverse-proxy/src/main/resources/application.yml | ||
|
||
#**********************************************************************************************************************# | ||
#***************************************************** VARIABLES ******************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
# server settings | ||
scheme: http | ||
hostname: localhost | ||
|
||
#reverse proxy | ||
reverse-proxy-port: 7080 | ||
|
||
# bff server | ||
bff-port: 9090 | ||
bff-prefix: /bff | ||
bff-server-uri: ${scheme}://${hostname}:${bff-port} | ||
|
||
# angular ui server | ||
angular-port: 4200 | ||
angular-prefix: /angular-ui | ||
# update scheme if you enable SSL in angular.json | ||
angular-server-uri: ${scheme}://${hostname}:${angular-port}${angular-prefix} | ||
|
||
#**********************************************************************************************************************# | ||
#************************************************** SPRING SETTINGS ***************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
## spring settings | ||
spring: | ||
# profile settings | ||
profiles: | ||
active: ssl | ||
# cloud gateway settings | ||
cloud: | ||
gateway: | ||
default-filters: | ||
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin | ||
routes: | ||
# SPAs assets | ||
- id: angular-ui | ||
uri: ${angular-server-uri} | ||
predicates: | ||
- Path=${angular-prefix}/** | ||
|
||
# BFF-server | ||
- id: bff | ||
uri: ${bff-server-uri} | ||
predicates: | ||
- Path=${bff-prefix}/** | ||
filters: | ||
- StripPrefix=1 | ||
|
||
#**********************************************************************************************************************# | ||
#************************************************** SERVER SETTINGS ***************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
# current server settings | ||
server: | ||
port: ${reverse-proxy-port} | ||
ssl: | ||
enabled: false | ||
|
||
#**********************************************************************************************************************# | ||
#************************************************* PROFILE SETTINGS ***************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
# spring profile settings | ||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: ssl | ||
server: | ||
ssl: | ||
enabled: false | ||
# key-store: classpath:proxyapp-keystore.p12 | ||
# key-store-password: tASH@Lc;5db{9q`z/64mCkX&]D~naUx=!B(>ZJT} | ||
# key-store-type: PKCS12 | ||
# key-alias: proxyapp | ||
scheme: http | ||
|
||
#**********************************************************************************************************************# | ||
#*********************************************** MANAGEMENT SETTINGS **************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
# endpoint settings | ||
management: | ||
endpoint: | ||
health: | ||
probes: | ||
enabled: true | ||
endpoints: | ||
web: | ||
exposure: | ||
include: health,info | ||
health: | ||
livenessstate: | ||
enabled: true | ||
readinessstate: | ||
enabled: true | ||
|
||
#**********************************************************************************************************************# | ||
#************************************************ LOGGING SETTINGS ****************************************************# | ||
#**********************************************************************************************************************# | ||
|
||
# logging configurations | ||
logging: | ||
level: | ||
root: INFO | ||
org: | ||
springframework: | ||
boot: INFO | ||
web: INFO | ||
cloud: | ||
gateway: DEBUG | ||
|
||
#**********************************************************************************************************************# | ||
#************************************************** END OF YAML *******************************************************# | ||
#**********************************************************************************************************************# |
Binary file not shown.