# Infrastructure locale SIOP V2 : PostgreSQL (pgvector+PostGIS), Redis, MinIO.
# Usage : pnpm infra:up / infra:down / infra:reset
#
# CONVENTION (demande du référent, leçon v1) : tous les services et conteneurs
# sont préfixés « siop2- » — sur le réseau partagé de Dokploy, un service nommé
# « postgres » ou « api » entre en collision avec les autres projets.
name: siop2-infra

services:
  siop2-postgres:
    container_name: siop2-postgres
    build: ./postgres
    image: siop2/postgres:18-pgvector-postgis
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-siop}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-siop}
      POSTGRES_DB: ${POSTGRES_DB:-siop}
    ports:
      - "5432:5432"
    volumes:
      - pg-data:/var/lib/postgresql
      - ./postgres/init.sql:/docker-entrypoint-initdb.d/10-extensions.sql:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U siop -d siop"]
      interval: 5s
      timeout: 3s
      retries: 10

  siop2-redis:
    container_name: siop2-redis
    image: redis:7.4.9-alpine
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 10

  siop2-minio:
    container_name: siop2-minio
    image: minio/minio:RELEASE.2025-09-07T16-13-09Z
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER:-siop}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-siop-minio}
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio-data:/data
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 5s
      timeout: 3s
      retries: 10

volumes:
  pg-data:
  minio-data:
