feat: 添加 Docker 一键部署支持,包括后端和前端 Dockerfile、docker-compose 配置及 Nginx 配置 (#112)
* feat: 添加 Docker 支持,包括后端和前端 Dockerfile、docker-compose 配置及 Nginx 配置 * feat: 添加 .dockerignore 文件,更新 Dockerfile 和 docker-compose 配置以支持数据持久化保存
This commit is contained in:
30
Dockerfile.frontend
Normal file
30
Dockerfile.frontend
Normal file
@@ -0,0 +1,30 @@
|
||||
# 前端 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 nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
# Nginx 会自动启动
|
||||
Reference in New Issue
Block a user