Dockerfile 877 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # 构建阶段
  2. FROM registry.cn-hangzhou.aliyuncs.com/wehome-base/node:20-alpine as builder
  3. # 设置 pnpm 源为 npmmirror
  4. RUN npm install -g pnpm --registry=https://registry.npmmirror.com
  5. RUN pnpm config set registry https://registry.npmmirror.com
  6. WORKDIR /app
  7. # 复制项目文件
  8. COPY package.json pnpm-lock.yaml ./
  9. # 安装依赖
  10. RUN pnpm install
  11. RUN pnpm install @tarojs/binding-linux-x64-musl
  12. # 复制源代码
  13. COPY . .
  14. # 构建项目
  15. RUN pnpm build:h5
  16. # 生产阶段
  17. FROM registry.cn-hangzhou.aliyuncs.com/wehome-base/nginx:latest
  18. # 创建必要的目录
  19. RUN mkdir -p /usr/share/nginx/app/dist
  20. # 删除默认的 nginx 配置
  21. RUN rm -rf /etc/nginx/nginx.conf
  22. # 复制自定义的 nginx 配置
  23. COPY ./nginx.conf /etc/nginx/nginx.conf
  24. # 从构建阶段复制构建好的文件
  25. COPY --from=builder /app/dist /usr/share/nginx/app/dist
  26. # 暴露端口
  27. EXPOSE 10000