# internal-app-platform 测试服后端依赖
#
# 启动 Postgres + Redis 给 backend 进程用。MinIO 由 docker-compose.minio.yml 单独管。
# 完全独立于 dev 的 ffoa-* 容器命名，避免和开发机 compose 冲突。
#
# 启动：
#   docker compose --env-file .env.backend-deps -f docker-compose.backend-deps.yml up -d
#
# 端口：本机回环 only（5432 / 6379），不暴露公网
# 数据卷：testserver-postgres-data / testserver-redis-data

services:
  postgres:
    image: postgres:16-alpine
    container_name: ffoa-testserver-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-ffoa}
      POSTGRES_USER: ${POSTGRES_USER:-ffoa}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set in .env.backend-deps}
      PGDATA: /var/lib/postgresql/data/pgdata
    ports:
      - "127.0.0.1:5432:5432"  # 仅本机访问
    volumes:
      - testserver-postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ffoa} -d ${POSTGRES_DB:-ffoa}"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - ffoa-network

  redis:
    image: redis:7.4-alpine
    container_name: ffoa-testserver-redis
    restart: unless-stopped
    command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:?Set in .env.backend-deps}
    ports:
      - "127.0.0.1:6379:6379"
    volumes:
      - testserver-redis-data:/data
    healthcheck:
      test: ["CMD-SHELL", "redis-cli -a $$REDIS_PASSWORD ping | grep -q PONG"]
      interval: 10s
      timeout: 3s
      retries: 5
    networks:
      - ffoa-network

networks:
  ffoa-network:
    external: true
    name: ffoa-network

volumes:
  testserver-postgres-data:
  testserver-redis-data:
