version: "3.9"

services:
  backend:
    build:
      context: ./backend
    image: wichteln-backend:latest
    restart: unless-stopped
    environment:
      DATABASE_URL: ${DATABASE_URL}
      DATABASE_USER: ${DATABASE_USER}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY}
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik-network"
      - "traefik.http.routers.wichteln-backend.rule=Host(`api-wichteln.byhaider.dev`)"
      - "traefik.http.routers.wichteln-backend.entrypoints=websecure"
      - "traefik.http.routers.wichteln-backend.tls=true"
      - "traefik.http.routers.wichteln-backend.tls.certResolver=cloudflare"
      - "traefik.http.services.wichteln-backend.loadbalancer.server.port=8080"
    networks:
      - backend
      - traefik-network

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

networks:
  traefik-network:
    external: true
  backend:
    external: true