services:
  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: nxtgauge
      POSTGRES_PASSWORD: nxtgauge_dev
      POSTGRES_DB: nxtgauge_db
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./scripts/seed.sql:/docker-entrypoint-initdb.d/seed.sql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U nxtgauge -d nxtgauge_db"]
      interval: 5s
      timeout: 5s
      retries: 10

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redisdata:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 10

  # ── Gateway ───────────────────────────────────────────────────────────────

  gateway:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-gateway:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    ports:
      - "9100:9100"
    environment:
      PORT: "9100"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
      RUST_LOG: info
      FRONTEND_URL: http://localhost:9201
      ADMIN_URL: http://localhost:9202
      USERS_SERVICE_URL: http://users:9101
      COMPANIES_SERVICE_URL: http://companies:9102
      JOBS_SERVICE_URL: http://jobs:9103
      JOB_SEEKERS_SERVICE_URL: http://job-seekers:9104
      CUSTOMERS_SERVICE_URL: http://customers:9105
      EMPLOYEES_SERVICE_URL: http://employees:9106
      PHOTOGRAPHERS_SERVICE_URL: http://photographers:9107
      TUTORS_SERVICE_URL: http://tutors:9108
      MAKEUP_ARTISTS_SERVICE_URL: http://makeup-artists:9109
      DEVELOPERS_SERVICE_URL: http://developers:9110
      VIDEO_EDITORS_SERVICE_URL: http://video-editors:9111
      GRAPHIC_DESIGNERS_SERVICE_URL: http://graphic-designers:9112
      SOCIAL_MEDIA_MANAGERS_SERVICE_URL: http://social-media-managers:9113
      FITNESS_TRAINERS_SERVICE_URL: http://fitness-trainers:9114
      CATERING_SERVICES_SERVICE_URL: http://catering-services:9115
      PAYMENTS_SERVICE_URL: http://payments:9116
      UGC_CONTENT_CREATORS_SERVICE_URL: http://ugc-content-creators:9117
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
      users:
        condition: service_started
      companies:
        condition: service_started
      jobs:
        condition: service_started
      job-seekers:
        condition: service_started
      customers:
        condition: service_started
      employees:
        condition: service_started
      photographers:
        condition: service_started
      tutors:
        condition: service_started
      makeup-artists:
        condition: service_started
      developers:
        condition: service_started
      video-editors:
        condition: service_started
      graphic-designers:
        condition: service_started
      social-media-managers:
        condition: service_started
      fitness-trainers:
        condition: service_started
      catering-services:
        condition: service_started
      payments:
        condition: service_started
      ugc-content-creators:
        condition: service_started

  # ── Core Services ─────────────────────────────────────────────────────────

  users:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-users:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9101"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  companies:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-companies:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9102"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  jobs:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-jobs:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9103"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
    depends_on:
      postgres:
        condition: service_healthy

  job-seekers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-job-seekers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9104"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  customers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-customers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9105"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  employees:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-employees:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9106"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  # ── 9 Profession Services ─────────────────────────────────────────────────

  photographers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-photographers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9107"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  tutors:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-tutors:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9108"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  makeup-artists:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-makeup-artists:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9109"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  developers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-developers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9110"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  video-editors:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-video-editors:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9111"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  graphic-designers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-graphic-designers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9112"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  social-media-managers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-social-media-managers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9113"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  fitness-trainers:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-fitness-trainers:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9114"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  catering-services:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-catering-services:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9115"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  # ── Payments ──────────────────────────────────────────────────────────────

  payments:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-payments:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9116"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  # ── UGC ───────────────────────────────────────────────────────────────────

  ugc-content-creators:
    platform: linux/amd64
    image: ci.nxtgauge.com/ashwin/nxtgauge-rust-ugc-content-creators:cd695514fe1b54b6b4b4505d75e4fe7318fb0198
    environment:
      PORT: "9117"
      MOCK_STORAGE: "true"
      DATABASE_URL: postgresql://nxtgauge:nxtgauge_dev@postgres:5432/nxtgauge_db
      REDIS_URL: redis://redis:6379
      JWT_SECRET: local_dev_jwt_secret
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

volumes:
  pgdata:
  redisdata:
