Skip to content

Commit

Permalink
docker-compose: add hot reload for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Feb 27, 2024
1 parent 1d0960b commit cb1f041
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
17 changes: 16 additions & 1 deletion backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencyManagement {
}

dependencies {
runtimeOnly("org.springframework.boot:spring-boot-devtools:$springVersion")
developmentOnly("org.springframework.boot:spring-boot-devtools")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-data-rest:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
Expand Down Expand Up @@ -99,4 +99,19 @@ tasks.named<Test>("test") {
}
}

// for hot-reload:
tasks.register<Copy>("getDependencies") {
from(sourceSets.main.get().runtimeClasspath)
into("runtime/")

doFirst {
val runtimeDir = File("runtime")
runtimeDir.deleteRecursively()
runtimeDir.mkdir()
}

doLast {
File("runtime").deleteRecursively()
}
}

4 changes: 1 addition & 3 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ sentry.proxy.port=8090
sentry.traces-sample-rate=1.0
sentry.environment=production
sentry.use-git-commit-id-as-release=true
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
# hot reload:
spring.devtools.livereload.enabled=true
2 changes: 2 additions & 0 deletions infra/configurations/backend/application-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ sentry.enabled=false
sentry.dsn=
sentry.traces-sample-rate=1.0
sentry.environment=localhost
# hot reload:
spring.devtools.livereload.enabled=true
2 changes: 1 addition & 1 deletion infra/docker/app/DockerfileLocalBack
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ COPY infra/configurations/backend ./configurations/
EXPOSE 80

# Run the backend application
CMD ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=/tmp/backend/configurations/'
CMD (./gradlew -t :bootJar) & ./gradlew bootRun -PskipDownload=true --args='--spring.profiles.active=local --spring.config.additional-location=/tmp/backend/configurations/'

0 comments on commit cb1f041

Please sign in to comment.