version: '3.8'
services:
    dojo-database:
        container_name: dojo-database
        image: mariadb:11.0
        environment:
            MARIADB_ROOT_PASSWORD: '${DATABASE_ROOT_PASSWORD}'
        networks:
            dojo-network:
                aliases:
                    - dojo-database
        volumes:
            - dojo-database:/var/lib/mysql
        restart: always

    adminer:
        container_name: adminer
        image: adminer:latest
        environment:
            - ADMINER_DEFAULT_SERVER=dojo-database
            - TZ=Europe/Zurich
            - ADMINER_PLUGINS=dump-alter dump-bz2 dump-date dump-json dump-xml dump-zip edit-foreign edit-textarea foreign-system json-column sql-log struct-comments tables-filter
            - ADMINER_DESIGN=hydra
        networks:
            dojo-network:
                aliases:
                    - adminer
        depends_on:
            - dojo-database
        restart: always

    dojo-api:
        container_name: dojo-api
        deploy:
            resources:
                limits:
                    cpus: '3.0'
        build:
            context: ./API/
            dockerfile: Dockerfile_ExpressAPI
        networks:
            dojo-network:
                aliases:
                    - dojo-api
        environment:
            LOGS_FOLDER: '/dojoLogs'
        volumes:
            - dojo-logs:/dojoLogsvolumes
            - /dojoFiles:/dojoFiles
        restart: always
        depends_on:
            - dojo-database

    dojo-frontend:
        container_name: dojo-frontend
        build:
            context: ./Frontend/
            dockerfile: Dockerfile_AngularApp
        networks:
            dojo-network:
                aliases:
                    - dojo-frontend
        restart: always
        depends_on:
            - dojo-api

    dojo-proxy:
        container_name: dojo-proxy
        build:
            context: ./
            dockerfile: Dockerfile_Dojo_Proxy
        restart: 'always'
        networks:
            dojo-network:
                aliases:
                    - dojo-proxy
        ports:
            - "80:80"
            - "443:443"
        depends_on:
            - dojo-api
            - dojo-frontend
            - adminer

networks:
    dojo-network:
volumes:
    dojo-database:
    dojo-logs: