From f4394ff4ee1111d815b5b5ae3981079746feba63 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Tue, 18 Oct 2022 11:02:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 042a600..3d4e2dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,30 +2,36 @@ FROM eclipse-temurin:17 as app-build ENV RELEASE=17 +RUN groupadd --gid 1000 spring-app \ + && useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app +USER spring-app:spring-app WORKDIR /opt/build -COPY ./target/spring-boot-*.jar ./application.jar +COPY ./target/*.jar ./application.jar RUN java -Djarmode=layertools -jar application.jar extract RUN $JAVA_HOME/bin/jlink \ - --add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' 'snapshot-dependencies/BOOT-INF/lib/' application.jar` \ + --add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*':'snapshot-dependencies/BOOT-INF/lib/*' application.jar` \ --strip-debug \ --no-man-pages \ --no-header-files \ --compress=2 \ - --output ./custom-jdk + --output jdk -FROM alpine:latest +FROM debian:buster-slim ARG BUILD_PATH=/opt/build ENV JAVA_HOME=/opt/jdk ENV PATH "${JAVA_HOME}/bin:${PATH}" -WORKDIR application +RUN groupadd --gid 1000 spring-app \ + && useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app +USER spring-app:spring-app +WORKDIR /opt/workspace -COPY --from=app-build $BUILD_PATH/custom-jdk $JAVA_HOME -COPY --from=app-build $BUILD_PATH/spring-boot-loader/ ./ +COPY --from=app-build $BUILD_PATH/jdk $JAVA_HOME COPY --from=app-build $BUILD_PATH/dependencies/ ./ +COPY --from=app-build $BUILD_PATH/spring-boot-loader/ ./ COPY --from=app-build $BUILD_PATH/snapshot-dependencies/ ./ COPY --from=app-build $BUILD_PATH/application/ ./