Files
teapot_system/backend/Dockerfile

23 lines
743 B
Docker
Raw Permalink 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.
FROM maven:3.8.7-eclipse-temurin-11 AS builder
WORKDIR /build
COPY pom.xml .
# 预下载依赖,利用缓存层加速后续构建
RUN mvn dependency:go-offline -B
COPY src ./src
# 打包并跳过测试
RUN mvn package -DskipTests
FROM eclipse-temurin:11-jre-alpine
WORKDIR /app
COPY --from=builder /build/target/*.jar app.jar
# 暴露给前端的反向代理端口
EXPOSE 8080
# 覆盖application.properties里的数据库地址将其挂载到独立volume中
ENV SPRING_DATASOURCE_URL=jdbc:sqlite:/app/data/teapot-system.db
# 挂载数据卷以持久化SQLite和潜在的图片文件
VOLUME /app/data
ENTRYPOINT ["java", "-Dspring.datasource.url=${SPRING_DATASOURCE_URL}", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]