version: '3'

services:
    app:
        build:
            context: .
            dockerfile: docker/dev/Dockerfile
        volumes:
            - .:/app
            - ./docker/dev/Caddyfile:/etc/caddy/Caddyfile
            - ./docker/dev/conf.d/app.ini:/usr/local/etc/php/conf.d/app.ini
        ports:
            - "${APP_PORT:-80}:80"
            - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
        environment:
            FRANKENPHP_CONFIG: "worker ./public/index.php"
            PHP_MEMORY_LIMIT: "512M"
            PHP_UPLOAD_MAX_FILESIZE: "42M"
            PHP_POST_MAX_SIZE: "42M"
            PHP_DISPLAY_ERRORS: "1"
            XDEBUG_MODE: "${XDEBUG_MODE:-off}"
        extra_hosts:
            - "host.docker.internal:host-gateway"
        depends_on:
            - redis
            - minio
            - mariadb
            - mailpit
        networks:
            - app_network

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

    minio:
        image: 'minio/minio:latest'
        ports:
            - '${FORWARD_MINIO_PORT:-9000}:9000'
            - '${FORWARD_MINIO_CONSOLE_PORT:-8900}:8900'
        environment:
            MINIO_ROOT_USER: '${MINIO_ROOT_USER:-sail}'
            MINIO_ROOT_PASSWORD: '${MINIO_ROOT_PASSWORD:-password}'
        volumes:
            - 'minio_data:/data/minio'
        networks:
            - app_network
        command: 'minio server /data/minio --console-address ":8900"'

    mariadb:
        image: 'mariadb:10'
        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:
            - 'mariadb_data:/var/lib/mysql'
        networks:
            - app_network

    mailpit:
        image: 'axllent/mailpit:latest'
        ports:
            - '${FORWARD_MAILPIT_PORT:-1025}:1025'
            - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
        networks:
            - app_network

networks:
    app_network:
        driver: bridge

volumes:
    redis_data:
        driver: local
    minio_data:
        driver: local
    mariadb_data:
        driver: local
