配置参考1(来自用户A)
FROM maven:3.9.7-amazoncorretto-21 as maven
WORKDIR /solon
COPY pom.xml pom.xml
COPY src src
RUN mvn compile assembly:single -q
FROM openjdk:21-jdk-slim
WORKDIR /solon
COPY --from=maven /solon/target/*.jar app.jar
EXPOSE 8080
CMD ["java", "-server", "-cp", "app.jar", "hello.Main"]
配置参考2(来自用户B)
FROM registry.cn-hangzhou.aliyuncs.com/yuwell-library/yuwell-maven:3.8.6-openjdk-8 AS MAVEN_BUILD
COPY pom.xml /build/
COPY . /build/
WORKDIR /build/
RUN mvn clean package -Dmaven.test.skip=true
FROM eclipse-temurin:8-jre-jammy
WORKDIR application
COPY --from=MAVEN_BUILD /build/target/*.jar application.jar
ENTRYPOINT ["java","-jar","application.jar"]