version: '3.8'

services:
  backend:
    build: 
      context: .
      dockerfile: backend/Dockerfile
    restart: always
    networks:
      - default
      - traefik_network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.slow-reader-api.rule=Host(`slow-reader.velouria.dev`) && (PathPrefix(`/api/`) || PathPrefix(`/ws/`))"
      - "traefik.http.routers.slow-reader-api.entrypoints=websecure"
      - "traefik.http.routers.slow-reader-api.tls.certresolver=myresolver"
      - "traefik.http.routers.slow-reader-api.middlewares=slow-reader-stripprefix"
      - "traefik.http.middlewares.slow-reader-stripprefix.stripprefix.prefixes=/api"
      - "traefik.http.services.slow-reader-api.loadbalancer.server.port=8000"
      - "traefik.docker.network=traefik_network"
      - "homepage.group=Tools"
      - "homepage.name=Slow Reader API"
      - "homepage.description=Reading Focus API"

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    restart: always
    depends_on:
      - backend
    networks:
      - default
      - traefik_network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.slow-reader.rule=Host(`slow-reader.velouria.dev`)"
      - "traefik.http.routers.slow-reader.entrypoints=websecure"
      - "traefik.http.routers.slow-reader.tls.certresolver=myresolver"
      - "traefik.http.services.slow-reader.loadbalancer.server.port=80"
      - "traefik.docker.network=traefik_network"
      - "homepage.group=Tools"
      - "homepage.name=Slow Reader"
      - "homepage.description=Focused Reading Experience"

networks:
  default:
    name: slow-reader_default
  traefik_network:
    external: true