Dockerfile 796 B

12345678910111213141516171819202122232425262728
  1. FROM maven:3.5-jdk-8 as base
  2. FROM openjdk:8-jdk-alpine
  3. # FROM openjdk:17-jdk-alpine
  4. RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
  5. COPY maven/settings.xml /root/.m2/settings.xml
  6. # ADD source dest
  7. FROM base as builder
  8. WORKDIR /app
  9. COPY . /app
  10. RUN mvn clean package && \
  11. mv target/springboot-note-0.0.1-SNAPSHOT.jar /app/target/springboot-note-0.0.1-SNAPSHOT.jar
  12. CMD [ "/bin/bash" ]
  13. FROM base as runner
  14. # USER java
  15. WORKDIR /app
  16. COPY --from=builder /app/target/springboot-note-0.0.1-SNAPSHOT.jar /app/target/springboot-note-0.0.1-SNAPSHOT.jar
  17. ARG JAVA_OPTS
  18. ENV JAVA_OPTS=$JAVA_OPTS
  19. EXPOSE 8080
  20. VOLUME [ "/app" ]
  21. # CMD [ "java", "-jar", "target/springboot-note-0.0.1-SNAPSHOT.jar"]
  22. ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]