修改Docker部署

This commit is contained in:
York
2025-02-28 12:48:15 +08:00
parent 9e83b512ce
commit bd591a6643
3 changed files with 32 additions and 8 deletions

View File

@ -1,17 +1,17 @@
# 构建阶段
FROM node:18-alpine as builder
FROM node:20-alpine as builder
# 设置工作目录
WORKDIR /app
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 首先只复制依赖相关文件
COPY package.json package-lock.json* ./
# 安装依赖
RUN npm install
RUN npm ci --quiet
# 复制源代码
# 然后复制其余源代码
COPY . .
# 构建项目
@ -23,6 +23,9 @@ FROM nginx:alpine
# 复制构建产物到 Nginx 目录
COPY --from=builder /app/dist /usr/share/nginx/html
# 添加自定义 nginx 配置以支持 SPA 路由
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 暴露 80 端口
EXPOSE 80