From 909dea471b8f6ab45fbae8d07469811bcf756f74 Mon Sep 17 00:00:00 2001 From: JustFiesta Date: Wed, 17 Apr 2024 13:38:59 +0200 Subject: [PATCH] Docker compose assesment --- Dockerfile | 2 +- compose.yaml | 50 +++++++++++++++++++++++--------------------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3ed44e55..956477fe7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,4 +18,4 @@ WORKDIR /app COPY --from=build /project/target/spring-petclinic-${app_version}.jar /app/java-application.jar -ENTRYPOINT ["java", "-jar", "java-application.jar"] +ENTRYPOINT [ "java", "-Dspring.profiles.active=postgres", "-jar", "java-application.jar"] diff --git a/compose.yaml b/compose.yaml index 8c167de4b..e23706e49 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,30 +20,26 @@ services: # database data between container restarts. The `db-password` secret is used # to set the database password. You must create `db/password.txt` and add # a password of your choosing to it before running `docker-compose up`. -# depends_on: -# db: -# condition: service_healthy -# db: -# image: postgres -# restart: always -# user: postgres -# secrets: -# - db-password -# volumes: -# - db-data:/var/lib/postgresql/data -# environment: -# - POSTGRES_DB=example -# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password -# expose: -# - 5432 -# healthcheck: -# test: [ "CMD", "pg_isready" ] -# interval: 10s -# timeout: 5s -# retries: 5 -# volumes: -# db-data: -# secrets: -# db-password: -# file: db/password.txt - + depends_on: + db: + condition: service_healthy + environment: + - POSTGRES_URL=jdbc:postgresql://db:5432/petclinic + db: + image: postgres + restart: always + volumes: + - db-data:/var/lib/postgresql/data + environment: + - POSTGRES_DB=petclinic + - POSTGRES_USER=petclinic + - POSTGRES_PASSWORD=petclinic + ports: + - 5432:5432 + healthcheck: + test: [ "CMD", "pg_isready", "-U", "petclinic" ] + interval: 10s + timeout: 5s + retries: 5 +volumes: + db-data: