version: '3'

services:
    devkit_lti1p3_traefik:
        container_name: devkit_lti1p3_traefik
        image: traefik:v2.4
        command:
            - '--api.insecure=true'
            - '--providers.docker=true'
            - '--providers.docker.exposedbydefault=false'
            - '--entrypoints.web.address=:80'
        networks:
            - devkit_lti1p3_network
        ports:
            - 80:80
            - 8080:8080
        volumes:
            - '/var/run/docker.sock:/var/run/docker.sock:ro'

    devkit_lti1p3_nginx:
        container_name: devkit_lti1p3_nginx
        image: nginx:stable
        networks:
            devkit_lti1p3_network:
                aliases:
                    - devkit-lti1p3.localhost
        labels:
            - 'traefik.enable=true'
            - 'traefik.http.routers.nginx.rule=Host(`devkit-lti1p3.localhost`)'
            - 'traefik.http.routers.nginx.entrypoints=web'
        expose:
          - 443
        volumes:
            - .:/var/www/html:cached
            - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:cached
        working_dir: /etc/nginx/conf.d

    devkit_lti1p3_phpfpm:
        container_name: devkit_lti1p3_phpfpm
        build:
            context: ./docker/phpfpm
        expose:
            - 9000
        networks:
            - devkit_lti1p3_network
        volumes:
            - .:/var/www/html:cached
        working_dir: /var/www/html

    devkit_lti1p3_redis:
        container_name: devkit_lti1p3_redis
        image: redis:latest
        command: ["redis-server", "--appendonly", "yes"]
        hostname: devkit_lti1p3_redis
        networks:
            - devkit_lti1p3_network
        ports:
            - "6379:6379"
        volumes:
            - devkit_lti1p3_redis_volume:/data

    devkit_lti1p3_redis_commander:
        container_name: devkit_lti1p3_redis_commander
        image: rediscommander/redis-commander:latest
        hostname: devkit_lti1p3_redis_commander
        networks:
            - devkit_lti1p3_network
        ports:
            - "8081:8081"
        expose:
            - 8081
        environment:
            - REDIS_HOSTS=local:devkit_lti1p3_redis:6379

volumes:
    devkit_lti1p3_redis_volume:
        driver: local

networks:
    devkit_lti1p3_network:
        driver: bridge
