services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        image: arise-app
        container_name: arise-app
        restart: unless-stopped
        working_dir: /var/www/html
        ports:
            - '8000:80'
            - '5173:5173'
        environment:
            APP_ENV: local
            DB_CONNECTION: mysql
            DB_HOST: mysql
            DB_PORT: 3306
            DB_DATABASE: arise
            DB_USERNAME: arise
            DB_PASSWORD: password
            REDIS_HOST: redis
        volumes:
            - '.:/var/www/html'
        networks:
            - arise-network
        depends_on:
            - mysql
            - redis

    mysql:
        image: 'mysql:8.0'
        container_name: arise-mysql
        ports:
            - '3306:3306'
        environment:
            MYSQL_ROOT_PASSWORD: 'root_password'
            MYSQL_DATABASE: 'arise'
            MYSQL_USER: 'arise'
            MYSQL_PASSWORD: 'password'
        volumes:
            - 'arise-mysql-data:/var/lib/mysql'
        networks:
            - arise-network
        healthcheck:
            test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
            retries: 3
            timeout: 5s

    redis:
        image: 'redis:alpine'
        container_name: arise-redis
        ports:
            - '6379:6379'
        volumes:
            - 'arise-redis-data:/data'
        networks:
            - arise-network
        healthcheck:
            test: ["CMD", "redis-cli", "ping"]
            retries: 3
            timeout: 5s

    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        container_name: arise-pma
        links:
            - mysql:db
        ports:
            - '8081:80'
        environment:
            PMA_HOST: mysql
            MYSQL_ROOT_PASSWORD: 'root_password'
        networks:
            - arise-network

networks:
    arise-network:
        driver: bridge

volumes:
    arise-mysql-data:
    arise-redis-data:
