-
-
Notifications
You must be signed in to change notification settings - Fork 194
Expand file tree
/
Copy pathDockerfile.multistage
More file actions
52 lines (40 loc) · 1.47 KB
/
Dockerfile.multistage
File metadata and controls
52 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 构建阶段 - Node.js 环境
FROM node:20.10.0 AS client-builder
WORKDIR /app/client
COPY app/client/package.json app/client/yarn.lock ./
RUN yarn install --frozen-lockfile
COPY app/client/ ./
RUN yarn build
# 构建阶段 - Maven 环境
FROM maven:3.8-openjdk-11 AS server-builder
WORKDIR /app/server
# 复制所有pom.xml文件以利用缓存
COPY app/server/.mvn/maven.config ./.mvn/
COPY app/server/pom.xml ./
COPY app/server/huntly-interfaces/pom.xml ./huntly-interfaces/
COPY app/server/huntly-server/pom.xml ./huntly-server/
COPY app/server/huntly-common/pom.xml ./huntly-common/
COPY app/server/huntly-jpa/pom.xml ./huntly-jpa/
# 下载依赖(缓存层)
RUN mvn dependency:go-offline -B
# 复制源码并构建(跳过前端相关插件)
COPY app/server/ ./
# 复制前端构建产物
COPY --from=client-builder /app/client/build ../client/build
RUN mvn clean package -B
# 运行阶段
FROM adoptopenjdk/openjdk11:latest
LABEL maintainer="lcomplete"
WORKDIR /app
VOLUME /data
RUN mkdir -p /data /data/lucene
# 从构建阶段复制 JAR 文件
COPY --from=server-builder /app/server/huntly-server/target/huntly-server-*.jar /app/server.jar
ENV JAVA_ARGS="-Xms128m -Xmx512m"
ENV VM_ARGS="-Duser.timezone=GMT+08"
ENV APP_ARGS=""
ENV PROFILE="default"
ENV PORT=80
EXPOSE ${PORT}
EXPOSE 443
ENTRYPOINT ["sh", "-c", "java $JAVA_ARGS $VM_ARGS -jar /app/server.jar --spring.profiles.active=$PROFILE --server.port=$PORT --huntly.dataDir=/data/ --huntly.luceneDir=/data/lucene $APP_ARGS" ]