version: '3.8'

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

volumes:
  postgres_data:

services:
  postgres:
    image: postgres:16-alpine
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    environment:
      POSTGRES_DB: iliacloud
      POSTGRES_USER: iliacloud
      POSTGRES_PASSWORD: f89d0cf58987e3d59b8376ba03141677a5c3a5c3990c808c
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U iliacloud"]
      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
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  backend:
    image: iliacloud-backend:latest
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.http.routers.iliacloud-api.rule=Host(`api.iliacloud.com`)
        - traefik.http.routers.iliacloud-api.entrypoints=websecure
        - traefik.http.routers.iliacloud-api.tls=true
        - traefik.http.routers.iliacloud-api.tls.certresolver=letsencrypt
        - traefik.http.services.iliacloud-api.loadbalancer.server.port=3000
        - traefik.http.routers.iliacloud-api-http.rule=Host(`api.iliacloud.com`)
        - traefik.http.routers.iliacloud-api-http.entrypoints=web
        - traefik.http.routers.iliacloud-api-http.middlewares=iliacloud-api-redirect@docker
        - traefik.http.middlewares.iliacloud-api-redirect.redirectscheme.scheme=https
    environment:
      NODE_ENV: production
      PORT: '3000'
      DATABASE_URL: postgresql://iliacloud:f89d0cf58987e3d59b8376ba03141677a5c3a5c3990c808c@postgres:5432/iliacloud
      JWT_SECRET: cc2264e11fb0699a373479021938013482a757d78c5b7b8583861394080054dd4c9d94a215da1f51e2f373f20d164eed5e3294e70af830df21727929b2715b3b
      JWT_EXPIRES_IN: 15m
      JWT_REFRESH_SECRET: 14dc2bd2ccd505a382deda0188b5e14d73173cc1ff9d222f8e830e6abbfc7b1c815960f3ce3181eb68bb2255b11d56cec0419902f6929115f05f899a43e3de8a
      JWT_REFRESH_EXPIRES_IN: 7d
      ENCRYPTION_KEY: 36ac10e7fda1d18b4a51ca1fc138ecc955ea8d9bef63a3ad347bae1532739e3f
      CORS_ORIGIN: https://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: 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
      STRIPE_PRICE_PRO_MONTHLY: price_1THr9q197Q6uWWA1yg3YWKgL
      STRIPE_PRICE_PRO_YEARLY: price_1THr9q197Q6uWWA1ldORS6t7
      STRIPE_PRICE_BUSINESS_MONTHLY: price_1THr9r197Q6uWWA16tpo1zJM
      STRIPE_PRICE_BUSINESS_YEARLY: price_1THr9r197Q6uWWA1cMV3271y
      STRIPE_PRICE_ENTERPRISE_MONTHLY: price_1TIQjf197Q6uWWA1hGkAlRCc
      STRIPE_PRICE_ENTERPRISE_YEARLY: price_1TIQjf197Q6uWWA1XozphkLG
      STRIPE_WEBHOOK_SECRET: whsec_Py4M0h3uKZy5axAZskCqoZoVcsR2ApBT
    networks:
      - internal
      - traefik-public

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