From 132bb2ce3b80cf1f060ce8672a46dd993b1c757e Mon Sep 17 00:00:00 2001 From: jrhlh <150811537+jrhlh@users.noreply.github.com> Date: Fri, 18 Jul 2025 22:26:19 +0800 Subject: [PATCH] 1 --- docker-compose.yml | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1c11ade..084e487 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,36 +1,30 @@ version: '3.8' services: backend: - image: python:3.11 # 直接使用Python 3.11官方镜像 + image: python:3.11-bookworm # 使用Debian-based的官方镜像 container_name: backend ports: - "7792:5000" volumes: - - ./back:/app # 挂载你的后端目录 - - backend-venv:/opt/venv # 持久化虚拟环境 + - ./back:/app working_dir: /app environment: - FLASK_ENV=development command: > - sh -c "if [ ! -f /opt/venv/bin/python ]; then - python -m venv /opt/venv && - . /opt/venv/bin/activate && - pip install -r requirements.txt; - fi && - . /opt/venv/bin/activate && - python app.py" # 确保你的入口文件是app.py + sh -c "python -m pip install --upgrade pip && + pip install -r requirements.txt && + python app.py" + depends_on: + - frontend frontend: - image: node:21 # 使用Node.js 21官方镜像 + image: node:21 container_name: frontend ports: - - "7793:5173" # Vite默认端口 + - "7793:5173" volumes: - ./platform:/app working_dir: /app environment: - NODE_ENV=development - command: sh -c "npm install && npm run dev" # 假设使用npm - -volumes: - backend-venv: # 持久化Python虚拟环境 \ No newline at end of file + command: sh -c "npm install && npm run dev" \ No newline at end of file