diff --git a/Dockerfiles/ Dockerfile-production/Dockerfile b/Dockerfiles/ Dockerfile-production/Dockerfile new file mode 100644 index 0000000..85c3a70 --- /dev/null +++ b/Dockerfiles/ Dockerfile-production/Dockerfile @@ -0,0 +1,41 @@ +# 构建阶段 +FROM m.daocloud.io/docker.io/library/node:22.14.0 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 + +# 安装pnpm +RUN npm install -g pnpm + +# 复制源代码 +COPY . . + +# 设置 pnpm 下载源 +RUN pnpm config set registry https://registry.npmmirror.com/ + +# 安装依赖 +RUN pnpm i --fetch-timeout 300000 + +# 构建项目 +RUN pnpm build + +# 部署阶段 +FROM m.daocloud.io/docker.io/library/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;"] \ No newline at end of file