services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: inboxkit
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: inboxkit
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - internal

  api:
    build:
      context: ../
      dockerfile: apps/api/Dockerfile
    environment:
      DATABASE_URL: postgresql://inboxkit:${POSTGRES_PASSWORD}@postgres:5432/inboxkit
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      POLAR_ACCESS_TOKEN: ${POLAR_ACCESS_TOKEN}
      JWT_SECRET: ${JWT_SECRET}
    depends_on:
      - postgres
    networks:
      - internal
      - dokploy-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.inboxkit-api.rule=Host(`inboxkit.eventium.com`) && PathPrefix(`/api`)"
      - "traefik.http.routers.inboxkit-api.entrypoints=websecure"
      - "traefik.http.routers.inboxkit-api.tls.certresolver=letsencrypt"
      - "traefik.http.services.inboxkit-api.loadbalancer.server.port=3000"

  web:
    build:
      context: ../
      dockerfile: apps/web/Dockerfile
    environment:
      NEXT_PUBLIC_API_URL: https://inboxkit.eventium.com/api
    networks:
      - dokploy-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.inboxkit-web.rule=Host(`inboxkit.eventium.com`)"
      - "traefik.http.routers.inboxkit-web.entrypoints=websecure"
      - "traefik.http.routers.inboxkit-web.tls.certresolver=letsencrypt"
      - "traefik.http.services.inboxkit-web.loadbalancer.server.port=3002"

volumes:
  pgdata:

networks:
  internal:
  dokploy-network:
    external: true
