version: "3.9"

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

      SHAREPOINT_TENANT_ID: ${SHAREPOINT_TENANT_ID}
      SHAREPOINT_CLIENT_ID: ${SHAREPOINT_CLIENT_ID}
      SHAREPOINT_CLIENT_SECRET: ${SHAREPOINT_CLIENT_SECRET}
      SHAREPOINT_SITE_ID: ${SHAREPOINT_SITE_ID}

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

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

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