From d24acf8390d7dc15f3d2f0e76b5c102445d8d305 Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Mon, 9 Sep 2024 12:01:06 +0200 Subject: [PATCH] use second dockerfile for local prod, restore old dockerfile and adjust docker-compose --- docker/Dockerfile | 4 +--- docker/local-prod/docker-compose.yml | 4 ++-- docker/local-prod/local-prod.Dockerfile | 12 ++++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 docker/local-prod/local-prod.Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile index 4af256761c..a4f2298a17 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,8 +9,6 @@ USER 1001 WORKDIR app-root/backend -RUN if [ -d "../backend/target" ]; then \ - cp -r --chown=1001 ../backend/target .; \ - fi +COPY --chown=1001 backend/target . ENTRYPOINT ["/bin/sh", "-c", "export BACKEND_VERSION=$(find . -type f -name 'backend-*.jar' -print -quit | sed -n 's/.*backend-\\(.*\\)\\.jar/\\1/p'); java -jar backend-${BACKEND_VERSION}.jar"] \ No newline at end of file diff --git a/docker/local-prod/docker-compose.yml b/docker/local-prod/docker-compose.yml index d719d12bfc..d6d39842a4 100644 --- a/docker/local-prod/docker-compose.yml +++ b/docker/local-prod/docker-compose.yml @@ -4,8 +4,8 @@ services: spring: container_name: spring build: - context: ./.. - dockerfile: Dockerfile + context: . + dockerfile: local-prod.Dockerfile restart: always ports: - 8080:8080 diff --git a/docker/local-prod/local-prod.Dockerfile b/docker/local-prod/local-prod.Dockerfile new file mode 100644 index 0000000000..db2807250f --- /dev/null +++ b/docker/local-prod/local-prod.Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:3.19 + +USER root + +RUN apk update && apk add --upgrade curl && apk --no-cache add openjdk17 + +RUN adduser --home /app-root --uid 1001 --disabled-password okr +USER 1001 + +WORKDIR app-root/backend + +ENTRYPOINT ["/bin/sh", "-c", "export BACKEND_VERSION=$(find . -type f -name 'backend-*.jar' -print -quit | sed -n 's/.*backend-\\(.*\\)\\.jar/\\1/p'); java -jar backend-${BACKEND_VERSION}.jar"] \ No newline at end of file