Files
jenkins-pipeline/Dockerfile/web/admin_web_Dockerfile
2025-11-20 14:51:44 +08:00

49 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ===============================
# 1) 依赖安装 + 构建阶段
# ===============================
FROM node:16-alpine AS build
WORKDIR /app
# 只拷贝 package.json加快缓存命中
COPY package.json ./
# 预先安装依赖(利用缓存)
RUN npm install --registry=https://registry.npmmirror.com
# 拷贝全部代码
COPY . .
# 通过构建参数传入构建环境(如 sit/test/prod
ARG BUILD_ENV=sit
ENV BUILD_ENV=${BUILD_ENV}
# 要求 package.json 中的 script 形如build:sit, build:test, build:prod
RUN npm run build:${BUILD_ENV}
# ===============================
# 2) 生产镜像阶段
# ===============================
FROM nginx:1.25-alpine AS runtime
# 清理默认 nginx 静态内容
RUN rm -rf /usr/share/nginx/html/*
# 拷贝 build 结果
COPY --from=build /app/dist /usr/share/nginx/html/
# 权限
RUN chmod -R 755 /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# docker build \
# --build-arg BUILD_ENV=${BUILD_ENV} \
# -t registry.xxx.com/your_project/web:${BUILD_NUMBER} .