25 lines
469 B
Docker
25 lines
469 B
Docker
|
FROM gradle:8.0.0-jdk17 AS build
|
||
|
WORKDIR /app
|
||
|
|
||
|
# 将Gradle的配置文件复制到镜像中
|
||
|
COPY gradlew .
|
||
|
COPY gradle gradle
|
||
|
COPY build.gradle .
|
||
|
COPY settings.gradle .
|
||
|
|
||
|
COPY src src
|
||
|
# 构建应用
|
||
|
RUN gradle bootJar
|
||
|
|
||
|
# 使用官方的Java运行时作为最终的运行环境
|
||
|
FROM openjdk:17-jdk-slim
|
||
|
WORKDIR /app
|
||
|
COPY --from=build/libs /app/build/libs/*.jar app.jar
|
||
|
|
||
|
# 设置应用运行的端口
|
||
|
EXPOSE 8080
|
||
|
|
||
|
|
||
|
# 启动应用
|
||
|
ENTRYPOINT ["java","-jar","/app/app.jar"]
|