services:
  # NginxProxyManager
  #---------------------------------------------------------------#
  # Authentik Database
  postgresql:
    image: docker.io/library/postgres:12-alpine
    mem_limit: 1g
    cpus: 1.0
    container_name: laravel-db
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 5s
    volumes:
      - ./database:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: ${PG_PASS:?database password required}
      POSTGRES_USER: ${PG_USER:-authentik}
      POSTGRES_DB: ${PG_DB:-authentik}
    env_file:
      - .env
    networks:
      - proxy

  laravel:
    build:
      context: ./htdocs
      dockerfile: Dockerfile
    container_name: laravel
    restart: unless-stopped
    volumes:
      - ./htdocs:/var/www/html
    ports:
      - "8088:8080"
    depends_on:
      postgresql:
        condition: service_healthy
    command: php artisan serve --host=0.0.0.0 --port=8080
    networks:
      - proxy
  python-listener:
    build:
      context: ./htdocs/listenerlis
      dockerfile: Dockerfile
    container_name: python-listener
    restart: unless-stopped
    volumes:
      - ./htdocs/listenerlis:/app
    ports:
      - "5000:5000"
      - "6001:6001"
    depends_on:
      postgresql:
        condition: service_healthy
    networks:
      - proxy
networks:
  proxy:
    external: true
