
Some checks failed
continuous-integration/drone/push Build is failing
- 将国内镜像源 docker.mirrors.ustc.edu.cn 替换为官方 Node.js 镜像 - 此更改可能会影响构建速度,视网络环境而定
35 lines
598 B
Docker
35 lines
598 B
Docker
# 构建阶段
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json .
|
|
COPY package-lock.json* .
|
|
|
|
# 设置npm镜像
|
|
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 .
|
|
|
|
# 设置npm镜像
|
|
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"] |