services:
  bricscad-server:
    build: .
    container_name: bricscad-server
    networks:
      - web
    volumes:
      - ./dwg_files:/app/dwg_files
      - ./database_files:/app/database_files
      - ./app.py:/app/app.py
      - ./wsgi.py:/app/wsgi.py
      - ./generate_manifest.py:/app/generate_manifest.py
      - ./scheduler_app.py:/app/scheduler_app.py
      - ./manifest.json:/app/manifest.json
    environment:
      - PYTHONUNBUFFERED=1
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=web"

      # Route ALL traffic through nginx (which proxies /api to Gunicorn)
      - "traefik.http.routers.scadlib.entrypoints=websecure"
      - "traefik.http.routers.scadlib.rule=Host(`libserver.scad.dev`)"
      - "traefik.http.routers.scadlib.tls=true"
      - "traefik.http.routers.scadlib.tls.certresolver=le"
      - "traefik.http.routers.scadlib.service=scadlib-service"
      - "traefik.http.services.scadlib-service.loadbalancer.server.port=80"

networks:
  web:
    external: true
