services:
    traefik:
        image: traefik:v2.11
        container_name: traefik
        command:
            - "--providers.docker=true"
            - "--providers.docker.exposedbydefault=false"
            - "--entrypoints.web.address=:80"
            - "--entrypoints.websecure.address=:443"
            - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
            - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
            - "--certificatesresolvers.letsencrypt.acme.email=contact@dine-management-software.com"
            - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
            - "./traefik/acme.json:/letsencrypt/acme.json"
        networks:
            - sail

    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.2
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.2/app
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - './:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.kondy.rule=Host(`kondy.dine-management-software.com`)"
            - "traefik.http.routers.kondy.entrypoints=websecure"
            - "traefik.http.routers.kondy.tls.certresolver=letsencrypt"
            - "traefik.http.services.kondy.loadbalancer.server.port=80"


    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail

    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail

    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - 1025:1025
            - 8025:8025
        networks:
            - sail

    phpmyadmin:
        image: phpmyadmin/phpmyadmin:latest
        container_name: phpmyadmin
        restart: always
        environment:
            PMA_HOST: mysql
            PMA_PORT: 3306
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
        depends_on:
            - mysql
        networks:
            - sail
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.kondydb.rule=Host(`kondy-db.dine-management-software.com`)"
            - "traefik.http.routers.kondydb.entrypoints=websecure"
            - "traefik.http.routers.kondydb.tls.certresolver=letsencrypt"
            - "traefik.http.services.kondydb.loadbalancer.server.port=80"


networks:
    sail:
        driver: bridge

volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local
    sailstorage:
        driver: local
    sailcache:
        driver: local
