automated_api/Dockerfile
lixin 29da78dcca build(docker): 重构 Dockerfile 并简化 CI 流程
- 重构 Dockerfile,使用多阶段构建以减小最终镜像大小
- 更新 .drone.yml,使用单一步骤完成构建和推送
- 移除不必要的依赖和配置,简化构建过程
- 设置生产环境变量和端口
2025-01-10 14:40:49 +08:00

33 lines
562 B
Docker

# 构建阶段
FROM node:18-alpine AS builder
WORKDIR /app
COPY package.json .
COPY package-lock.json* .
RUN npm config set registry https://registry.npmmirror.com/ && \
npm install
COPY . .
RUN npm run build
# 运行阶段
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json .
COPY --from=builder /app/bootstrap.js .
RUN npm config set registry https://registry.npmmirror.com/ && \
npm install --production
ENV NODE_ENV=production
ENV PORT=8001
EXPOSE 8001
CMD ["node", "bootstrap.js"]