添加 Dockerfiles/Dockerfile-Staging/Dockerfile
This commit is contained in:
parent
4119982525
commit
7bc6c8113e
|
|
@ -0,0 +1,38 @@
|
|||
# 构建阶段
|
||||
FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/node:20.19.6 AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 npm 镜像源
|
||||
RUN npm config set registry https://registry.npmmirror.com/
|
||||
RUN npm config set fetch-retries 3
|
||||
RUN npm config set fetch-retry-mintimeout 5000
|
||||
RUN npm config set fetch-retry-maxtimeout 60000
|
||||
|
||||
# 复制 package.json
|
||||
COPY package.json ./
|
||||
|
||||
# 安装依赖
|
||||
RUN npm install
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
# 构建项目(跳过类型检查)
|
||||
RUN npm run build
|
||||
|
||||
# 部署阶段
|
||||
FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/nginx:alpine
|
||||
|
||||
# 复制构建产物到 Nginx 目录
|
||||
COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html
|
||||
|
||||
# 复制 Nginx 配置
|
||||
COPY Dockerfiles/Dockerfile-Staging/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
# 启动 Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Loading…
Reference in New Issue