From 38ae73c017a10e9dec9e7147d220d0bd106fc23f Mon Sep 17 00:00:00 2001 From: Vince God <10594559@qq.com> Date: Sun, 10 Aug 2025 05:44:42 +0800 Subject: [PATCH] add dockerfile --- GIT_PROCESS.md | 28 ++++++++++++++++++++++++++++ ruoyi-fastapi-backend/Dockerfile | 29 +++++++++++++++++++++++++++++ ruoyi-fastapi-frontend/Dockerfile | 30 ++++++++++++++++++++++++++++++ ruoyi-fastapi-frontend/nginx.conf | 23 +++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 GIT_PROCESS.md create mode 100644 ruoyi-fastapi-backend/Dockerfile create mode 100644 ruoyi-fastapi-frontend/Dockerfile create mode 100644 ruoyi-fastapi-frontend/nginx.conf diff --git a/GIT_PROCESS.md b/GIT_PROCESS.md new file mode 100644 index 0000000..d25a98d --- /dev/null +++ b/GIT_PROCESS.md @@ -0,0 +1,28 @@ + + +# 1. 添加上游仓库(首次配置时) +git remote add upstream https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI.git + +# 2. 获取上游更新 +git fetch upstream + +# 3. 切换到本地主分支 +git checkout main + +# 4. 合并上游更新 +git merge upstream/main + +# 5. 解决冲突(如有) +# 手动编辑冲突文件后: +git add <冲突文件> +git commit -m "Resolve merge conflicts" + +# 6. 推送更新到fork +git push origin main + +# 7. 使用git remove -v查看远程的配置 +D:\cdchenw\develop\projects\svi\ruoyi\RuoYi-Vue3-FastAPI> git remote -v +origin git@gitee.com:svi-vincegod/RuoYi-Vue3-FastAPI.git (fetch) +origin git@gitee.com:svi-vincegod/RuoYi-Vue3-FastAPI.git (push) +upstream https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI.git (fetch) +upstream https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI.git (push) \ No newline at end of file diff --git a/ruoyi-fastapi-backend/Dockerfile b/ruoyi-fastapi-backend/Dockerfile new file mode 100644 index 0000000..2137275 --- /dev/null +++ b/ruoyi-fastapi-backend/Dockerfile @@ -0,0 +1,29 @@ +# 构建阶段 +FROM python:3.9-slim as builder + +WORKDIR /app +COPY requirements.txt . + +# 安装依赖 +RUN pip install --user -r requirements.txt + +# 生产阶段 +FROM python:3.9-slim + +WORKDIR /app + +# 从构建阶段复制已安装的Python依赖 +COPY --from=builder /root/.local /root/.local +COPY . . + +# 确保脚本可执行 +RUN chmod +x /app/start.sh + +# 添加Python依赖到PATH +ENV PATH=/root/.local/bin:$PATH + +# 暴露端口 +EXPOSE 9099 + +# 启动应用 +CMD ["sh", "start.sh"] diff --git a/ruoyi-fastapi-frontend/Dockerfile b/ruoyi-fastapi-frontend/Dockerfile new file mode 100644 index 0000000..fd9fac4 --- /dev/null +++ b/ruoyi-fastapi-frontend/Dockerfile @@ -0,0 +1,30 @@ +# 构建阶段 +FROM node:16-alpine as builder + +# 设置工作目录 +WORKDIR /app + +# 复制package.json和package-lock.json +COPY package*.json ./ + +# 安装依赖 +RUN npm install --registry=https://registry.npm.taobao.org + +# 复制项目文件 +COPY . . + +# 构建生产环境应用 +RUN npm run build:prod + +# 生产阶段 +FROM nginx:alpine + +# 复制nginx配置 +COPY --from=builder /app/dist /usr/share/nginx/html +COPY ./nginx.conf /etc/nginx/conf.d/default.conf + +# 暴露端口 +EXPOSE 80 + +# 启动nginx +CMD ["nginx", "-g", "daemon \ No newline at end of file diff --git a/ruoyi-fastapi-frontend/nginx.conf b/ruoyi-fastapi-frontend/nginx.conf new file mode 100644 index 0000000..6f3ab85 --- /dev/null +++ b/ruoyi-fastapi-frontend/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 1y; + add_header Cache-Control "public, no-transform"; + } + + # API代理配置 (按需修改) + # location /api/ { + # proxy_pass http://backend:8000; + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # } +} \ No newline at end of file -- Gitee