version: '3'

services:
    app:
        build: .
        container_name: app
        entrypoint: dockerize -template ./.docker/app/.env:.env -wait tcp://db:3306 -timeout 40s ./.docker/entrypoint.sh
        environment: 
            - DB_HOST=db
            - DB_DATABASE=aplicativo_gridtiesolar
            - DB_USERNAME=root
            - DB_PASSWORD=ag203577
        volumes: 
            - .:/var/www
        networks: 
            - app-network
        depends_on:
            - db
            - redis

    nginx:
        build: .docker/nginx
        container_name: nginx
        restart: always
        tty: true
        ports: 
            - "8000:80"
        volumes: 
            - .:/var/www
        networks: 
            - app-network
        depends_on:
            - app
            
    db:
        build: .docker/mysql
        command: --innodb-use-native-aio=0
        container_name: db
        restart: always
        tty: true
        ports:
            - "3306:3306"
        volumes: 
            - ./.docker/dbdata:/var/lib/mysql
        environment: 
            - MYSQL_DATABASE=aplicativo_gridtiesolar
            - MYSQL_USER=root
            - MYSQL_ROOT_PASSWORD=ag203577            
        networks: 
            - app-network
    
    redis: 
        image: redis:alpine
        expose: 
            - 6379
        networks: 
            - app-network
        
networks: 
    app-network:
        driver: bridge