version: '3.7'
services:
    web:
        image: nginx:alpine3.18-slim
        volumes:
            - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
        ports:
            - ${DOCKER_NGINX_PORT}:80
        depends_on:
            - db
            - redis
            - app
            - reverb
    app:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: DEVELOP
        depends_on:
            - db
            - redis
            - reverb
        volumes:
            - ./app/application:/var/www/html
    queue:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: DEVELOP
        depends_on:
            - db
            - redis
        environment:
            CONTAINER_ROLE: queue
        volumes:
            - ./app/application:/var/www/html
    reverb:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: DEVELOP
        depends_on:
            - db
            - redis
        environment:
            CONTAINER_ROLE: websockets
        ports:
            - ${DOCKER_WEBSOCKET_PORT}:9000
        volumes:
            - ./app/application:/var/www/html
    scheduler:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: DEVELOP
        depends_on:
            - db
            - redis
        environment:
            CONTAINER_ROLE: scheduler
        volumes:
            - ./app/application:/var/www/html
    redis:
        image: redis:3.0-alpine
    db:
        image: mysql:8.0.33
        command: --default-authentication-plugin=mysql_native_password
        ports:
            - ${DOCKER_DB_PORT}:3306
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${DB_DATABASE}
            MYSQL_USER: ${DB_USERNAME}
            MYSQL_PASSWORD: ${DB_PASSWORD}
        volumes:
            - ./db/data:/var/lib/mysql
    swagger:
        image: swaggerapi/swagger-ui
        environment:
            URLS: "[ { url: '/swagger.json', name: '/swagger.json' } ]"
            BASE_URL: /api-docs

    artisan:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: ARTISAN
        user: "${UID}:${GID}"
        volumes:
            - ./app/application:/var/www/html

    composer:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: COMPOSER
        user: "${UID}:${GID}"
        volumes:
            - ./app/application:/var/www/html

    npm:
        build:
            context: app
            dockerfile: docker/Dockerfile
            target: NPM
        user: "${UID}:${GID}"
        volumes:
            - ./app/application:/var/www/html
