Skip to content

Instantly share code, notes, and snippets.

@tariqulislam
Last active April 16, 2023 17:10
Show Gist options
  • Select an option

  • Save tariqulislam/04d23a982cda5607efac3f77cdf66e85 to your computer and use it in GitHub Desktop.

Select an option

Save tariqulislam/04d23a982cda5607efac3f77cdf66e85 to your computer and use it in GitHub Desktop.
# Build Stage for Spring boot application image
FROM openjdk:8-jdk-alpine as build
WORKDIR /app
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
RUN chmod +x ./mvnw
# download the dependency if needed or if the pom file is changed
RUN ./mvnw dependency:go-offline -B
COPY src src
RUN ./mvnw package -DskipTests
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
# Production Stage for Spring boot application image
FROM openjdk:8-jre-alpine as production
ARG DEPENDENCY=/app/target/dependency
# Copy the dependency application file from build stage artifact
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
# Run the Spring boot application
ENTRYPOINT ["java", "-cp", "app:app/lib/*","com.example.starter.StaterApplication"]
@LeandroLimaPRO
Copy link

ERROR: Service 'pulse-api' failed to build: COPY failed: stat /var/lib/docker/overlay2/371690df3a6b845468e60d533061bf2ee9ac068fd9cc9c2111a66388276080c3/merged/app/target/dependency/BOOT-INF/lib: no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment