version: "3.5"

services:   
  nginx:
    image: nginx
    container_name: nginx
    user: root
    ports:
      - ${PORT_DOCKER}:80
    volumes:
      - ${DIRETORIO_APP_DOCKER}:/app
      - ./docker/nginx:/etc/nginx/conf.d
    extra_hosts:
      localhost.com.br: 127.0.0.1
    environment: 
      - NGINX_PORT=${PORT_DOCKER}
    restart: always    

  #docker run -it --name mysql -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql (configure a variavel de ambiente MYSQL_ROOT_PASSWORD = ${DB_PASSWORD})
  #docker exec -it mysql mysql -uinov -p
  #sudo apt-get install php7.0-mysql
  mysql:
    container_name: mysql
    image: mysql:8.1
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
      #MYSQL_ALLOW_PASSWORD: true
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql      
    ports:
      - '3306:3306'
    volumes:
      - ./docker/mysql/sql:/docker-entrypoint-initdb.d

  php-fpm:
    build: docker/php-fpm
    container_name: php_fpm
    volumes:
      - ${DIRETORIO_APP_DOCKER}:/app
      - ./docker/php-fpm/conf/custom.ini:/opt/bitnami/php/etc/conf.d/custom.ini
    environment:
      XDEBUG_CONFIG: remote_host=172.18.0.1
      PHP_IDE_CONFIG: "serverName=xdebug-docker"
      APP_ENV: local
      CONTAINER_ROLE: app
    extra_hosts:
      localhost.com.br: 127.0.0.1
    working_dir: /app
    restart: always
 
  php-fpm-queue:
    container_name: php_fpm_queue
    image: docker-novo-site-vennx_php-fpm
    depends_on:
      - php-fpm
    volumes:
      - ${DIRETORIO_APP_DOCKER}:/app
      - ./docker/php-fpm/conf/custom.ini:/opt/bitnami/php/etc/conf.d/custom.ini
    ports: 
      - 9002:9000
    environment:
      APP_ENV: local
      CONTAINER_ROLE: queue
    extra_hosts:
      localhost.com.br: 127.0.0.1
    restart: always
  
  redis:
    image: redis:latest
    container_name: redis_server
    command: redis-server --requirepass 123456
    environment:
      REDISCLI_AUTH: 123456
    volumes:
      - ${DIRETORIO_APP_DOCKER}/redis-data:/data
    ports:
      - '6379:6379'
    restart: always

  php-fpm-scheduler:
    container_name: php_fpm_scheduler
    image: docker-novo-site-vennx_php-fpm
    depends_on:
      - php-fpm
    volumes:
      - ${DIRETORIO_APP_DOCKER}:/app
      - ./docker/php-fpm/conf/custom.ini:/opt/bitnami/php/etc/conf.d/custom.ini
    ports:
      - 9001:9000
    environment:
      APP_ENV: local
      CONTAINER_ROLE: scheduler
    extra_hosts:
      localhost: 127.0.0.1
    restart: always
    