services: db: image: postgres:17-alpine restart: unless-stopped environment: POSTGRES_DB: laser_data POSTGRES_USER: laser_app POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?请在.env中设置POSTGRES_PASSWORD} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U laser_app -d laser_data"] interval: 10s timeout: 5s retries: 5 web: build: context: . args: PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple} restart: unless-stopped ports: ["${APP_PORT:-5980}:8000"] environment: DATABASE_URL: postgresql+psycopg://laser_app:${POSTGRES_PASSWORD}@db:5432/laser_data APP_SECRET: ${APP_SECRET:?请在.env中设置APP_SECRET} ADMIN_USERNAME: ${ADMIN_USERNAME:-admin} ADMIN_PASSWORD: ${ADMIN_PASSWORD:?请在.env中设置ADMIN_PASSWORD} BACKUP_KEEP_DAYS: ${BACKUP_KEEP_DAYS:-30} volumes: - ./backups:/app/backups depends_on: db: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3)"] interval: 15s timeout: 5s retries: 5 start_period: 20s volumes: postgres_data: