From a11c9c0a1ac6c9bf091cd80becc89d0fff64f9cb Mon Sep 17 00:00:00 2001 From: xDepcio Date: Wed, 27 Nov 2024 17:48:17 +0100 Subject: [PATCH] d --- Dockerfile | 12 ++++++++++++ Dockerfile-og | 4 ++++ docker-compose-og.yml | 25 +++++++++++++++++++++++++ docker-compose.yml | 35 ++++++++++++++++------------------- 4 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 Dockerfile create mode 100644 Dockerfile-og create mode 100644 docker-compose-og.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..29fae58f6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM maven:3.8.7-openjdk-18-slim AS build + +RUN mkdir /app +COPY . /app +WORKDIR /app +RUN mvn package + +# Minimal rintime image - only JRE +# FROM gcr.io/distroless/java21-debian12 AS runtime +# COPY --from=build /app/target/*.jar /app.jar +ENTRYPOINT [ "java" ] +CMD [ "-jar", "-Dspring.profiles.active=postgres", "/app.jar" ] diff --git a/Dockerfile-og b/Dockerfile-og new file mode 100644 index 000000000..cb852420f --- /dev/null +++ b/Dockerfile-og @@ -0,0 +1,4 @@ +FROM eclipse-temurin:21-jre-alpine + +COPY ./target/spring-petclinic-3.3.0-SNAPSHOT.jar /app.jar +CMD ["java", "-jar", "app.jar"] diff --git a/docker-compose-og.yml b/docker-compose-og.yml new file mode 100644 index 000000000..8fdaacbc6 --- /dev/null +++ b/docker-compose-og.yml @@ -0,0 +1,25 @@ +services: + mysql: + image: mysql:9.1 + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD= + - MYSQL_ALLOW_EMPTY_PASSWORD=true + - MYSQL_USER=petclinic + - MYSQL_PASSWORD=petclinic + - MYSQL_DATABASE=petclinic + volumes: + - "./conf.d:/etc/mysql/conf.d:ro" + profiles: + - mysql + postgres: + image: postgres:17.0 + ports: + - "5432:5432" + environment: + - POSTGRES_PASSWORD=petclinic + - POSTGRES_USER=petclinic + - POSTGRES_DB=petclinic + profiles: + - postgres diff --git a/docker-compose.yml b/docker-compose.yml index 8fdaacbc6..5f694d7f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,22 @@ services: - mysql: - image: mysql:9.1 + server: + build: + context: . ports: - - "3306:3306" + - 8080:8080 environment: - - MYSQL_ROOT_PASSWORD= - - MYSQL_ALLOW_EMPTY_PASSWORD=true - - MYSQL_USER=petclinic - - MYSQL_PASSWORD=petclinic - - MYSQL_DATABASE=petclinic + - POSTGRES_URL=jdbc:postgresql://db:5432/petclinic + command: ["-jar", "-Dspring.profiles.active=postgres", "/app.jar"] + db: + image: postgres:17.1 + restart: always volumes: - - "./conf.d:/etc/mysql/conf.d:ro" - profiles: - - mysql - postgres: - image: postgres:17.0 - ports: - - "5432:5432" + - db-data:/var/lib/postgresql/data environment: - - POSTGRES_PASSWORD=petclinic - - POSTGRES_USER=petclinic - POSTGRES_DB=petclinic - profiles: - - postgres + - POSTGRES_USER=petclinic + - POSTGRES_PASSWORD=petclinic + ports: + - 5432:5432 +volumes: + db-data: