
Some checks failed
continuous-integration/drone/push Build is failing
- 移除原有的 npm 安装命令 - 添加 pnpm 的全局安装命令 - 使用 pnpm 配置镜像源 - 替换生产环境中的 npm 安装命令为 pnpm
37 lines
658 B
Docker
37 lines
658 B
Docker
# 构建阶段
|
|
FROM node:22-alpine AS builder
|
|
#
|
|
WORKDIR /app
|
|
|
|
COPY package.json .
|
|
COPY package-lock.json* .
|
|
|
|
# 设置npm镜像
|
|
RUN npm config set registry https://registry.npmmirror.com
|
|
|
|
RUN npm install -g pnpm
|
|
RUN pnpm config set registry https://registry.npmmirror.com
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
|
|
|
# 运行阶段
|
|
FROM node:22-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/package.json .
|
|
COPY --from=builder /app/bootstrap.js .
|
|
|
|
# 设置npm镜像
|
|
RUN pnpm config set registry https://registry.npmmirror.com
|
|
RUN pnpm install --production
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=8001
|
|
|
|
EXPOSE 8001
|
|
|
|
CMD ["node", "bootstrap.js"] |