- Deleted Dockerfiles for backend and frontend, along with the associated Nginx configuration and localization debugging script, to streamline the project structure and eliminate unnecessary files.
31 lines
545 B
Docker
31 lines
545 B
Docker
# 前端 Dockerfile (多阶段构建)
|
|
FROM node:22-alpine AS builder
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 复制 package.json 和 package-lock.json
|
|
COPY web/package.json web/package-lock.json* ./
|
|
|
|
# 安装依赖
|
|
RUN npm ci
|
|
|
|
# 复制前端源代码
|
|
COPY web/ .
|
|
# 构建前端
|
|
RUN npm run build
|
|
|
|
# 生产阶段 - 使用 Nginx
|
|
FROM nginx:alpine
|
|
|
|
# 复制构建产物
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# 复制 Nginx 配置
|
|
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# Nginx 会自动启动
|