version: '3.8' services: # PostgreSQL - 共用資料庫 postgres: image: postgres:15-alpine container_name: tobiichiGPT-postgres restart: unless-stopped environment: POSTGRES_DB: tobiichiGPT POSTGRES_USER: tobiichi3227 POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - postgres-data:/var/lib/postgresql/data networks: - tobiichiGPT-network healthcheck: test: ["CMD-SHELL", "pg_isready -U tobiichi3227"] interval: 10s timeout: 5s retries: 5 # API 轉接層 - 偽裝 OpenAI API api: image: python:3.11-slim container_name: tobiichiGPT-api restart: unless-stopped ports: - "18000:8000" environment: - DB_HOST=postgres - DB_PORT=5432 - DB_NAME=tobiichiGPT - DB_USER=tobiichi3227 - DB_PASSWORD=${DB_PASSWORD} volumes: - ./api:/app working_dir: /app command: > sh -c " pip install --no-cache-dir -r requirements.txt && python server.py " networks: - tobiichiGPT-network depends_on: postgres: condition: service_healthy # Open WebUI - 用戶對話介面 openwebui: image: ghcr.io/open-webui/open-webui:main container_name: tobiichiGPT-ui restart: unless-stopped ports: - "13000:3000" environment: - DATABASE_URL=postgresql://tobiichi3227:${DB_PASSWORD}@postgres:5432/tobiichiGPT - WEBUI_AUTH=True volumes: - openwebui-data:/app/backend/data networks: - tobiichiGPT-network depends_on: postgres: condition: service_healthy # NocoDB - 管理員回覆介面 nocodb: image: nocodb/nocodb:latest container_name: tobiichiGPT-nocodb restart: unless-stopped ports: - "18080:8080" environment: - NC_DB=pg://postgres:5432?u=tobiichi3227&p=${DB_PASSWORD}&d=tobiichiGPT networks: - tobiichiGPT-network depends_on: postgres: condition: service_healthy networks: tobiichiGPT-network: driver: bridge name: tobiichiGPT-network # 固定網路名稱,讓 proxy stack 可以連接 volumes: postgres-data: openwebui-data: