2025-01-10 14:37:00 +08:00
|
|
|
# 构建阶段
|
2025-01-10 15:02:55 +08:00
|
|
|
FROM node:22-alpine AS builder
|
2025-01-10 14:58:30 +08:00
|
|
|
#
|
2025-01-09 16:10:19 +08:00
|
|
|
WORKDIR /app
|
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
COPY package.json .
|
|
|
|
COPY package-lock.json* .
|
2025-01-09 16:10:19 +08:00
|
|
|
|
2025-01-10 14:44:51 +08:00
|
|
|
# 设置npm镜像
|
2025-01-10 14:40:49 +08:00
|
|
|
RUN npm config set registry https://registry.npmmirror.com/ && \
|
|
|
|
npm install
|
2025-01-09 16:10:19 +08:00
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN npm run build
|
2025-01-09 16:10:19 +08:00
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
# 运行阶段
|
2025-01-10 15:02:55 +08:00
|
|
|
FROM node:22-alpine
|
2025-01-09 16:10:19 +08:00
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
WORKDIR /app
|
2025-01-10 13:02:23 +08:00
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
COPY --from=builder /app/package.json .
|
|
|
|
COPY --from=builder /app/bootstrap.js .
|
2025-01-10 13:02:23 +08:00
|
|
|
|
2025-01-10 14:44:51 +08:00
|
|
|
# 设置npm镜像
|
2025-01-10 14:40:49 +08:00
|
|
|
RUN npm config set registry https://registry.npmmirror.com/ && \
|
|
|
|
npm install --production
|
2025-01-10 13:02:23 +08:00
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV PORT=8001
|
2025-01-09 16:10:19 +08:00
|
|
|
|
|
|
|
EXPOSE 8001
|
|
|
|
|
2025-01-10 14:37:00 +08:00
|
|
|
CMD ["node", "bootstrap.js"]
|