services:
  # API Web Sentinel
  web-sentinel-api:
    build:
      context: ../..
      dockerfile: deployment/Dockerfile.api
    container_name: web-sentinel-api
    restart: unless-stopped
    expose:
      - "5000"
    environment:
      - DATABASE_URL=postgresql://websentinel_user:${POSTGRES_PASSWORD}@web-sentinel-db:5432/websentinel_prod
      - WEB_SENTINEL_POSTGRES_URL=${DATABASE_URL}
      - WEB_SENTINEL_LICENSE_BACKEND=postgresql
      - REDIS_URL=redis://web-sentinel-redis:6379/0
      - WEB_SENTINEL_SECRET_KEY=${WEB_SENTINEL_SECRET_KEY}
      - FLASK_ENV=production
    networks:
      - faildaily-ssl-network
    depends_on:
      - web-sentinel-db
      - web-sentinel-redis
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web-sentinel-api.rule=Host(`api.web-sentinel.taaazzz-prog.fr`)"
      - "traefik.http.routers.web-sentinel-api.tls=true"
      - "traefik.http.routers.web-sentinel-api.tls.certresolver=letsencrypt"
      - "traefik.http.services.web-sentinel-api.loadbalancer.server.port=5000"

  # Base de données PostgreSQL
  web-sentinel-db:
    image: postgres:15-alpine
    container_name: web-sentinel-db
    restart: unless-stopped
    environment:
      - POSTGRES_USER=websentinel_user
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=websentinel_prod
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - faildaily-ssl-network

  # Cache Redis
  web-sentinel-redis:
    image: redis:7-alpine
    container_name: web-sentinel-redis
    restart: unless-stopped
    networks:
      - faildaily-ssl-network

  # Documentation
  web-sentinel-docs:
    image: nginx:alpine
    container_name: web-sentinel-docs
    restart: unless-stopped
    volumes:
      - ./docs:/usr/share/nginx/html
      - ./nginx-docs.conf:/etc/nginx/conf.d/default.conf
    networks:
      - faildaily-ssl-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web-sentinel-docs.rule=Host(`docs.web-sentinel.taaazzz-prog.fr`)"
      - "traefik.http.routers.web-sentinel-docs.tls=true"
      - "traefik.http.routers.web-sentinel-docs.tls.certresolver=letsencrypt"

  # Installation
  web-sentinel-install:
    image: nginx:alpine
    container_name: web-sentinel-install
    restart: unless-stopped
    volumes:
      - ./install:/usr/share/nginx/html
      - ./nginx-install.conf:/etc/nginx/conf.d/default.conf
    networks:
      - faildaily-ssl-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web-sentinel-install.rule=Host(`install.web-sentinel.taaazzz-prog.fr`)"
      - "traefik.http.routers.web-sentinel-install.tls=true"
      - "traefik.http.routers.web-sentinel-install.tls.certresolver=letsencrypt"

  # Interface Web
  web-sentinel-web:
    image: nginx:alpine
    container_name: web-sentinel-web
    restart: unless-stopped
    volumes:
      - ./web:/usr/share/nginx/html
      - ./nginx-web.conf:/etc/nginx/conf.d/default.conf
    networks:
      - faildaily-ssl-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web-sentinel-web.rule=Host(`web-sentinel.taaazzz-prog.fr`)"
      - "traefik.http.routers.web-sentinel-web.tls=true"
      - "traefik.http.routers.web-sentinel-web.tls.certresolver=letsencrypt"

volumes:
  postgres_data:

networks:
  faildaily-ssl-network:
    external: true
    name: faildaily_faildaily-ssl-network