services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
            args:
                NODE_VERSION: 20
        container_name: api-gop-angra
        env_file: .env
        volumes:
            - ./:/var/www/html
            - ./docker/config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
        ports:
            - "${APP_PORT:-8010}:80"
            - "${VITE_PORT:-5180}:5173"
        depends_on:
            db:
                condition: service_healthy
        restart: always

    db:
        image: mysql:8.0.40
        container_name: api-gop-angra-db
        environment:
            MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
            MYSQL_DATABASE: ${DB_DATABASE}
            MYSQL_ROOT_HOST: "%"
        volumes:
            - ./docker/volumes/mysql:/var/lib/mysql
        ports:
            - "${FORWARD_DB_PORT:-3320}:3306"
        healthcheck:
            test:
                [
                    "CMD-SHELL",
                    "mysqladmin ping -h 127.0.0.1 -uroot -p$MYSQL_ROOT_PASSWORD --silent",
                ]
            interval: 10s
            timeout: 5s
            retries: 10
            start_period: 30s
        restart: always
