Skip to content

Commit

Permalink
Add commands for development
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Dec 20, 2024
1 parent c3db73a commit ddfdac1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,27 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

tasks.register("runDb") {
description = "Run the database in a container."
doLast {
exec {
commandLine 'docker', 'compose', 'up', '-d', 'postgres'
}
}
}

tasks.register("cleanDb") {
description = "Stop and remove the database container and volumes."
doLast {
exec {
commandLine 'docker', 'compose', 'down', '-v', 'postgres'
}
}
}

tasks.register("testLocal") {
description = "Start the database container if needed and run the tests."
dependsOn tasks.named("runDb")
finalizedBy tasks.named("test")
}
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ services:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=db
ports:
- "5432:5432"
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5

0 comments on commit ddfdac1

Please sign in to comment.