diff --git a/Dockerfile b/Dockerfile index 3ad3359d..e00fe98d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,21 @@ -# 构建阶段 -FROM node:20-alpine AS builder - -WORKDIR /app - -# 复制依赖清单 -COPY package.json pnpm-lock.yaml ./ - -# 设置 npm 和 pnpm 使用国内镜像源(关键!) -RUN npm config set registry https://registry.npmmirror.com && \ - npm install -g pnpm && \ - pnpm config set registry https://registry.npmmirror.com - -# 安装依赖(现在会走淘宝镜像) -RUN pnpm install --frozen-lockfile +# 使用轻量级的 Nginx 镜像 +FROM nginx:alpine -# 复制源码并构建 -COPY . . -RUN pnpm run build:prod # 生成 dist-prod 目录 +# 复制自定义 Nginx 配置(如果有) +RUN rm -f /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/default.conf -# 运行阶段 -FROM nginx:alpine +# 将本地 dist 目录复制到容器中 +COPY dist /usr/share/nginx/html -# 复制前端产物 -COPY --from=builder /app/dist-prod /usr/share/nginx/html +# 暴露 8088 端口 +EXPOSE 8088 -# 复制 Nginx 配置 -COPY nginx.conf /etc/nginx/nginx.conf +# 创建启动脚本 +RUN echo -e '#!/bin/sh\n\ +echo "Waiting for MySQL/Redis/MinIO to start..."\n\ +sleep 15\n\ +nginx -g "daemon off;"' > /start.sh && \ + chmod +x /start.sh -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["/start.sh"] \ No newline at end of file