Files
api-client/Dockerfile
2025-05-05 18:14:22 +08:00

35 lines
669 B
Docker
Raw 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 node:18 AS build
# 设置工作目录
WORKDIR /app
# 拷贝 package.json 并安装依赖(可利用缓存)
COPY package*.json ./
COPY . .
ENV CI=true
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN npm install pnpm -g
RUN pnpm install --force
# 拷贝全部代码并构建
RUN pnpm run build
# 2⃣ 生产部署阶段(用 nginx 托管)
FROM 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;"]