version: '3.8'

networks:
  internal-dev:
    driver: overlay
  traefik-public:
    external: true

volumes:
  postgres_data_dev:

services:
  postgres:
    image: postgres:16-alpine
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    environment:
      POSTGRES_DB: iliacloud_dev
      POSTGRES_USER: iliacloud_dev
      POSTGRES_PASSWORD: 6ba55c1703bc62e79e1a5618d0701a473b2decf62a4560e3
    volumes:
      - postgres_data_dev:/var/lib/postgresql/data
    networks:
      - internal-dev
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U iliacloud_dev"]
      interval: 10s
      timeout: 5s
      retries: 5

  gotenberg:
    image: gotenberg/gotenberg:8
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--api-timeout=30s"
    networks:
      - internal-dev
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  backend:
    image: iliacloud-backend-dev:latest
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.http.routers.iliacloud-dev-api.rule=Host(`dev.api.iliacloud.com`)
        - traefik.http.routers.iliacloud-dev-api.entrypoints=websecure
        - traefik.http.routers.iliacloud-dev-api.tls=true
        - traefik.http.routers.iliacloud-dev-api.tls.certresolver=letsencrypt
        - traefik.http.services.iliacloud-dev-api.loadbalancer.server.port=3000
        - traefik.http.routers.iliacloud-dev-api-http.rule=Host(`dev.api.iliacloud.com`)
        - traefik.http.routers.iliacloud-dev-api-http.entrypoints=web
        - traefik.http.routers.iliacloud-dev-api-http.middlewares=iliacloud-dev-api-redirect@docker
        - traefik.http.middlewares.iliacloud-dev-api-redirect.redirectscheme.scheme=https
    environment:
      NODE_ENV: production
      PORT: '3000'
      DATABASE_URL: postgresql://iliacloud_dev:6ba55c1703bc62e79e1a5618d0701a473b2decf62a4560e3@postgres:5432/iliacloud_dev
      JWT_SECRET: 8746c6c196c8a26e80f62894a5b9dad600209cd5bd79a627a8ac4e3a9dfc01d6dacfea6863032ed698e94fbc0bf5c31bff3ec1ce779c6c618124b25279bb0f94
      JWT_EXPIRES_IN: 15m
      JWT_REFRESH_SECRET: 983dab3e396497b3f4e296febb99cca356f0f020f45ceaafeffd888a575a5d1a7f33e64c475c0bbf307c19c06ca80d72e891c0946520ec43b733515ec32966ab
      JWT_REFRESH_EXPIRES_IN: 7d
      ENCRYPTION_KEY: 36ac10e7fda1d18b4a51ca1fc138ecc955ea8d9bef63a3ad347bae1532739e3f
      CORS_ORIGIN: https://dev.app.iliacloud.com
      COOKIE_DOMAIN: .iliacloud.com
      GOTENBERG_URL: http://gotenberg:3000
      VAPID_EMAIL: contact@taaazzz-prog.fr
      VAPID_PRIVATE_KEY: OWn7dLk4lDW9nV640hO19g3Mj-BZs9opgATmB1do1JE
      VAPID_PUBLIC_KEY: BNel-DaxWh-x_gB9fvuT3MrsEFw7SJOtQg00PoXdDM9e3n8j8ehWEmz_50wmjniE8GegkLnhlMym5Atxw-B-ieM
      SMTP_HOST: ssl0.ovh.net
      SMTP_USER: contact@iliacloud.com
      SMTP_PASSWORD: "@51008473@ZoE@"
      STRIPE_SECRET_KEY: sk_test_REMPLACER_PAR_CLE_TEST_STRIPE
      STRIPE_PRICE_PRO_MONTHLY: price_test_pro_monthly
      STRIPE_PRICE_PRO_YEARLY: price_test_pro_yearly
      STRIPE_PRICE_BUSINESS_MONTHLY: price_test_business_monthly
      STRIPE_PRICE_BUSINESS_YEARLY: price_test_business_yearly
      STRIPE_PRICE_ENTERPRISE_MONTHLY: price_test_enterprise_monthly
      STRIPE_PRICE_ENTERPRISE_YEARLY: price_test_enterprise_yearly
      STRIPE_WEBHOOK_SECRET: whsec_test_REMPLACER
    networks:
      - internal-dev
      - traefik-public

  frontend:
    image: iliacloud-frontend-dev:latest
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.http.routers.iliacloud-dev.rule=Host(`dev.app.iliacloud.com`)
        - traefik.http.routers.iliacloud-dev.entrypoints=websecure
        - traefik.http.routers.iliacloud-dev.tls=true
        - traefik.http.routers.iliacloud-dev.tls.certresolver=letsencrypt
        - traefik.http.services.iliacloud-dev.loadbalancer.server.port=80
        - traefik.http.routers.iliacloud-dev-http.rule=Host(`dev.app.iliacloud.com`)
        - traefik.http.routers.iliacloud-dev-http.entrypoints=web
        - traefik.http.routers.iliacloud-dev-http.middlewares=iliacloud-dev-redirect@docker
        - traefik.http.middlewares.iliacloud-dev-redirect.redirectscheme.scheme=https
    networks:
      - traefik-public
