Код: Выделить всё
# stage 1
FROM eclipse-temurin:8-alpine AS build
ENV HOME=/usr/app
RUN mkdir -p $HOME
WORKDIR $HOME
ADD . $HOME
RUN --mount=type=cache,target=/root/.m2 ./mvnw -f $HOME/pom.xml clean install
# stage 2
FROM eclipse-temurin:8-alpine
ARG JAR_FILE=/usr/app/target/*.jar
COPY --from=build $JAR_FILE /app/runner.jar
ARG ENV_FILE=/usr/app/.env
COPY --from=build $ENV_FILE /app/.env
ARG INIT_FILE=/usr/app/contextinit.sh
COPY --from=build $INIT_FILE /app/contextinit.sh
RUN chmod 777 /app/contextinit.sh
CMD ["/bin/bash","/app/contextinit.sh"]
ENTRYPOINT java -jar -Dspring.profiles.active=prod /app/runner.jar
Подробнее здесь: https://stackoverflow.com/questions/795 ... entrypoint