AutoMedinfo/backend/Dockerfile

32 lines
596 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用Maven构建
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
# 复制pom.xml并下载依赖利用Docker缓存
COPY pom.xml .
RUN mvn dependency:go-offline -B
# 复制源代码并构建
COPY src ./src
RUN mvn clean package -DskipTests
# 运行阶段
FROM eclipse-temurin:17-jre
WORKDIR /app
# 复制构建好的jar包
COPY --from=build /app/target/*.jar app.jar
# 创建必要的目录
RUN mkdir -p /app/downloads /app/logs
# 暴露端口
EXPOSE 8080
# 运行应用
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE:-prod}", "app.jar"]