
services:
  postgres:
    image: postgres:16
    container_name: streamhub-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      TZ: ${TZ}
    volumes:
      - ./data/postgres:/var/lib/postgresql/data

  mediamtx:
    image: bluenviron/mediamtx:1.17.0
    container_name: streamhub-mediamtx
    restart: unless-stopped
    ports:
      - "1935:1935"
      - "8888:8888"
      - "8889:8889"
      - "8189:8189/udp"
      - "127.0.0.1:9997:9997"
      - "127.0.0.1:9998:9998"
    volumes:
      - ./mediamtx/mediamtx.yml:/mediamtx.yml:ro

  backend:
    build: ./backend
    container_name: streamhub-backend
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - postgres
      - mediamtx
    volumes:
      - ./data/logs:/app/logs

  caddy:
    image: caddy:2.8
    container_name: streamhub-caddy
    restart: unless-stopped
    depends_on:
      - backend
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - ./data/caddy:/data
      - ./data/caddy_config:/config
