version: '3.8'

services:
  app:
    image: docker.jiranit.com/bbb_dashboard:latest
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - db
    command: php artisan serve --host=0.0.0.0 --port=8000
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.bbb.rule=Host(`${APP_DOMAIN:-bbb.local}`)"
      - "traefik.http.routers.bbb.entrypoints=websecure"
      - "traefik.http.routers.bbb.tls.certresolver=lets-encrypt"
      - "traefik.http.services.bbb.loadbalancer.server.port=8000"
    networks:
      - traefik-net

  db:
    image: mysql:8.0-buster
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-secret}
      MYSQL_DATABASE: ${DB_DATABASE:-bbb_pilot}
      MYSQL_USER: ${DB_USERNAME:-bbbpilot}
      MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - traefik-net

volumes:
  db_data:

networks:
  traefik-net:
    external: true
