Files
api-client/Dockerfile
zzc 7354dbfab5
All checks were successful
continuous-integration/drone/tag Build is passing
build: drone node version npm nginx
2026-01-05 10:15:29 +08:00

36 lines
795 B
Docker
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 1⃣ 构建阶段
FROM images.lihailezzc.com/library/node:20-alpine as build
# 设置工作目录
WORKDIR /app
# 拷贝 package.json 并安装依赖(可利用缓存)
COPY package*.json ./
COPY . .
ENV CI=true
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN npm config set registry https://registry.npmmirror.com
RUN npm install pnpm -g
RUN pnpm install --force
# 拷贝全部代码并构建
RUN pnpm run build
# 2⃣ 生产部署阶段(用 nginx 托管)
FROM images.lihailezzc.com/library/nginx:alpine
# 拷贝构建好的 dist 到 nginx 的 html 目录
COPY --from=build /app/dist /usr/share/nginx/html
# 拷贝自定义 nginx 配置(可选)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 默认端口
EXPOSE 80
# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]