services:
  postgresql:
    image: postgres:16
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
      interval: 1s
      timeout: 2s
      retries: 300
    env_file:
    - env.d/postgresql
    - env.d/common
    volumes:
    - ./data/databases/backend:/var/lib/postgresql/data

  redis:
    image: redis:5

  backend:
    image: lasuite/meet-backend:latest
    user: ${DOCKER_USER:-1000}
    restart: always
    env_file:
    - .env
    - env.d/common
    - env.d/postgresql
    healthcheck:
      test: ["CMD", "python", "manage.py", "check"]
      interval: 15s
      timeout: 30s
      retries: 20
      start_period: 10s
    depends_on:
      postgresql:
        condition: service_healthy
        restart: true
      redis:
        condition: service_started
      livekit:
        condition: service_started

  frontend:
    image: lasuite/meet-frontend:latest
    user: "${DOCKER_USER:-1000}"
    entrypoint:
    - /docker-entrypoint.sh
    command: ["nginx", "-g", "daemon off;"]
    env_file:
    - .env
    - env.d/common
    # Uncomment and set your values if using our nginx proxy example
    # environment:
    # - VIRTUAL_HOST=${MEET_HOST} # used by nginx proxy 
    # - VIRTUAL_PORT=8083 # used by nginx proxy
    # - LETSENCRYPT_HOST=${MEET_HOST} # used by lets encrypt to generate TLS certificate
    depends_on:
      backend:
        condition: service_healthy
    volumes:
    - ./default.conf.template:/etc/nginx/templates/docs.conf.template
# Uncomment if using our nginx proxy example
#    networks:
#    - proxy-tier
#    - default

  livekit:
    image: livekit/livekit-server:latest
    command: --config /config.yaml
    ports:
    - 7881:7881/tcp
    - 7882:7882/udp
    volumes:
      - ./livekit-server.yaml:/config.yaml
    # Uncomment and set your values if using our nginx proxy example
    # environment:
    # - VIRTUAL_HOST=${LIVEKIT_HOST} # used by nginx proxy 
    # - VIRTUAL_PORT=7880 # used by nginx proxy
    # - LETSENCRYPT_HOST=${LIVEKIT_HOST} # used by lets encrypt to generate TLS certificate
    depends_on:
      redis:
        condition: service_started
# Uncomment if using our nginx proxy example
#    networks:
#    - proxy-tier
#    - default

# Uncomment if using our nginx proxy example
#networks:
#  proxy-tier:
#    external: true
