services:
  frontend:
    build: ./frontend
    depends_on:
      backend:
        condition: service_healthy
    restart: unless-stopped
    healthcheck:
      test:
      - CMD-SHELL
      - curl -sf http://localhost:3000/ || exit 1
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s
    networks:
    - hms-network
    - coolify
  backend:
    build: ./backend
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:
    - DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://hms:hms@postgres:5432/hms}
    - REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
    - RENTMAN_API_TOKEN=${RENTMAN_API_TOKEN}
    - JWT_SECRET=${JWT_SECRET}
    - SMTP_HOST=${SMTP_HOST}
    - SMTP_PORT=${SMTP_PORT:-587}
    - SMTP_USER=${SMTP_USER}
    - SMTP_PASSWORD=${SMTP_PASSWORD}
    - SMTP_FROM=${SMTP_FROM:-info@hms-licht-ton.de}
    - CORS_ORIGINS=${CORS_ORIGINS:-https://hms.media-on.de,http://localhost:3000}
    - ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
    - ADMIN_PASSWORD=${ADMIN_PASSWORD}
    - MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN:-}
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
    healthcheck:
      test:
      - CMD
      - python
      - -c
      - import urllib.request; urllib.request.urlopen("http://localhost:8000/api/health")
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    networks:
    - hms-network
  postgres:
    image: postgres:16-alpine
    volumes:
    - postgres_data:/var/lib/postgresql/data
    environment:
    - POSTGRES_USER=hms
    - POSTGRES_PASSWORD=hms
    - POSTGRES_DB=hms
    - POSTGRES_HOST_AUTH_METHOD=trust
    restart: unless-stopped
    healthcheck:
      test:
      - CMD-SHELL
      - pg_isready -U hms -d hms
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 5s
    networks:
    - hms-network
  redis:
    image: redis:7-alpine
    volumes:
    - redis_data:/data
    restart: unless-stopped
    healthcheck:
      test:
      - CMD
      - redis-cli
      - ping
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 5s
    networks:
    - hms-network
networks:
  hms-network:
    driver: bridge
  coolify:
    external: true
volumes:
  postgres_data: null
  redis_data: null
