version: '2'
services:

  mysql:
      image: mariadb
      volumes:
           - ./docker/.data/db:/var/lib/mysql
           - ./docker/config/database:/docker-entrypoint-initdb.d
      restart: always
      environment:
          MYSQL_ROOT_PASSWORD: root
          MYSQL_DATABASE: dev_portal
#            MYSQL_USER: cartasciganas
#            MYSQL_PASSWORD: cartasciganas
      ports:
          - 3306:3306

  phpmyadmin:
      image: phpmyadmin/phpmyadmin
      ports:
          - 8081:80
      environment:
          # - PMA_ARBITRARY=1 # This line allows you to have the GUI display a 'server' field to connect to any server you wish
          - PMA_HOST=mysql
          - PMA_USER=root
          - PMA_PASSWORD=root
      links:
          - mysql

  redis_db:
      image: redis:latest
      restart: always
      environment:
          REDIS_URL: redis://redis_db:6379

  node_js:
      image: node:4     ## node.js v4
      volumes:          ## adds app folder to the container
          - ./chat:/node_app
#          - /home/caiosilva/html/chat:/node_app
      depends_on:
          - mysql
          - redis_db
      ports:            ## publish ports
          - "10040:10040"
      working_dir: /node_app         ## uses work dir /node_app
      entrypoint: node app.js   ## starts application

  webserver:
      image: nginx:latest
      ports:
          - 80:80
          - 443:443
      volumes:
          - .:/app
#          - /home/caiosilva/html:/app
          - ./docker/config/site.conf:/etc/nginx/conf.d/site.conf
#          - /home/caiosilva/html/docker/config/site.conf:/etc/nginx/conf.d/site.conf
      links:
          - php
      container_name: nginx

  php:
      build:
        dockerfile: ./php.dockerfile
        context: ./docker
      image: caiosantossp/php71-fpm
      container_name: php71-fpm
      volumes:
          - .:/app
          - ./docker/config/php-fpm.conf:/etc/php7/php-fpm.conf
          - ./docker/config/php.ini:/usr/local/etc/php/php.ini
      depends_on:
          - mysql
          - redis_db