diff --git a/Dockerfile b/Dockerfile index 97b6f8a..77b4060 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,24 @@ -# ========= 阶段1:构建 ========= -FROM node:20-alpine AS builder +FROM node:latest AS builder -WORKDIR /app +RUN mkdir -p /workspace + +WORKDIR /workspace -# 使用国内镜像加速(可选但强烈建议) RUN npm config set registry https://registry.npmmirror.com -# 直接用 npm 全局安装 pnpm(最稳,最快) -RUN npm install -g pnpm +RUN cd /workspace -# 复制依赖文件先缓存 -COPY package.json pnpm-lock.yaml ./ +RUN git clone https://github.com/setube/ogame-vue-ts.git -# 安装依赖 -RUN pnpm install --frozen-lockfile +RUN mv ./ogame-vue-ts/* . ; rm -rf ./ogame-vue-ts/ -# 复制源码并构建 -COPY . . -RUN pnpm run build +RUN npm install -g pnpm ; pnpm install ; npx vite build -# ========= 阶段2:运行时 ========= FROM nginx:alpine -# 复制构建产物 -COPY --from=builder /app/dist /usr/share/nginx/html +RUN rm -rf /usr/share/nginx/html/* -# 解决 Vue Router history 模式 404 问题 -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /workspace/docs /usr/share/nginx/html EXPOSE 80 - CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file