services:
  backend:
    build:
      context: ./backend
    image: gastro-backend:latest
    container_name: gastro-backend
    restart: unless-stopped
    environment:
      DATABASE_URL: ${DATABASE_URL}
      DATABASE_USER: ${DATABASE_USER}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}

      JWT_SECRET: ${JWT_SECRET}
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik-network"
      - "traefik.http.routers.gastro-backend.rule=Host(`api-gastro.byhaider.dev`)"
      - "traefik.http.routers.gastro-backend.entrypoints=websecure"
      - "traefik.http.routers.gastro-backend.tls=true"
      - "traefik.http.routers.gastro-backend.tls.certResolver=cloudflare"
      - "traefik.http.services.gastro-backend.loadbalancer.server.port=8080"
    networks:
      - postgresql
      - traefik-network

  frontend:
    build:
      context: ./frontend
    image: gastro-frontend:latest
    container_name: gastro-frontend
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.gastro-frontend.rule=Host(`gastro.byhaider.dev`)"
      - "traefik.http.routers.gastro-frontend.entrypoints=websecure"
      - "traefik.http.routers.gastro-frontend.tls=true"
      - "traefik.http.routers.gastro-frontend.tls.certResolver=cloudflare"
      - "traefik.http.services.gastro-frontend.loadbalancer.server.port=80"
    networks:
      - traefik-network

networks:
  traefik-network:
    external: true
  postgresql:
    external: true