services:

  webserver:
    image: chocobozzz/peertube-webserver:latest
    restart: ${restartPolicy}
    depends_on:
      - peertube
    networks:
      - peertubeNet
        #ports:
        #- "80:80"
        #- "443:443"
    volumes:
      - assets:/var/www/peertube/peertube-latest/client/dist:ro
      - data:/var/www/peertube/storage
    env_file:
      - ../../secret/env-${peertubeServName}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${peertubeServName}.rule=Host(`${peertubeHost}.${domain}`)"      
      - "traefik.docker.network=peertubeNet"

  peertube:
    image: chocobozzz/peertube:production-bookworm
    container_name: ${peertubeServName}
    restart: ${restartPolicy}
    depends_on:
      - postgres
      - redis
    networks:
      - peertubeNet
    volumes:
      # Remove the following line if you want to use another webserver/proxy or test PeerTube in local
      - assets:/app/client/dist
      - data:/data
      - config:/config
    env_file:
      - ../../secret/env-${peertubeServName}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${peertubeServName}.rule=Host(`${peertubeHost}.${domain}`)"      
      - "traefik.docker.network=peertubeNet"
      - "traefik.http.services.${peertubeServName}.loadbalancer.server.port=9000"
        #traefik.frontend.rule: "Host:videos.kaz.bzh"
        #traefik.port: "9000"
        #      traefik.frontend.redirect.entryPoint: https

  postgres:
    image: postgres:13-alpine
    container_name: ${peertubeDBName}
    restart: ${restartPolicy}
    networks:
      - peertubeNet
    volumes:
      - db:/var/lib/postgresql/data
    env_file:
      - ../../secret/env-${peertubeDBName}
    labels:
      traefik.enable: "false"

  redis:
    image: redis:6-alpine
    container_name: peertubeCache
    restart: ${restartPolicy}
    networks:
      - peertubeNet
    env_file:
      - ../../secret/env-${peertubeServName}
    volumes:
      - redis:/data
    labels:
      traefik.enable: "false"

volumes:
  assets:
  data:
  config:
  db:
  redis:

networks:
  peertubeNet:
    external: true
    name: peertubeNet
