This commit is contained in:
jrhlh
2025-07-18 22:26:19 +08:00
parent ecc8387ee6
commit 132bb2ce3b

View File

@ -1,36 +1,30 @@
version: '3.8' version: '3.8'
services: services:
backend: backend:
image: python:3.11 # 直接使用Python 3.11官方镜像 image: python:3.11-bookworm # 使用Debian-based的官方镜像
container_name: backend container_name: backend
ports: ports:
- "7792:5000" - "7792:5000"
volumes: volumes:
- ./back:/app # 挂载你的后端目录 - ./back:/app
- backend-venv:/opt/venv # 持久化虚拟环境
working_dir: /app working_dir: /app
environment: environment:
- FLASK_ENV=development - FLASK_ENV=development
command: > command: >
sh -c "if [ ! -f /opt/venv/bin/python ]; then sh -c "python -m pip install --upgrade pip &&
python -m venv /opt/venv && pip install -r requirements.txt &&
. /opt/venv/bin/activate && python app.py"
pip install -r requirements.txt; depends_on:
fi && - frontend
. /opt/venv/bin/activate &&
python app.py" # 确保你的入口文件是app.py
frontend: frontend:
image: node:21 # 使用Node.js 21官方镜像 image: node:21
container_name: frontend container_name: frontend
ports: ports:
- "7793:5173" # Vite默认端口 - "7793:5173"
volumes: volumes:
- ./platform:/app - ./platform:/app
working_dir: /app working_dir: /app
environment: environment:
- NODE_ENV=development - NODE_ENV=development
command: sh -c "npm install && npm run dev" # 假设使用npm command: sh -c "npm install && npm run dev"
volumes:
backend-venv: # 持久化Python虚拟环境