version: '3.2'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile-nginx
    env_file:
      - ./.env
    ports:
    - "8080:80"
    - "8081:443"
    networks:
      - attendizenet
    volumes:
      - .:/usr/share/nginx/html/attendize
    depends_on:
      - php
  php:
    build:
      context: .
      dockerfile: Dockerfile-php
    env_file:
      - ./.env
    depends_on:
      - db
      - maildev
      - redis
    volumes:
      - .:/usr/share/nginx/html/attendize
    networks: 
      - attendizenet
  composer:
    build:
      context: .
      dockerfile: Dockerfile-composer
    depends_on:
      - php
    volumes:
      - .:/usr/share/nginx/html/attendize
    networks:
      - attendizenet
  php-worker:
    build:
      context: .
      dockerfile: Dockerfile-php
    depends_on:
      - db
      - maildev
      - redis
    volumes:
      - .:/usr/share/nginx/html/attendize
    command: php artisan queue:work --daemon
    networks:
      - attendizenet
  db:
    image: mysql:5.7.23
    restart: always
    env_file:
      - ./.env
    environment:
      MYSQL_ROOT_PASSWORD: "yes"
      MYSQL_HOST: ${DB_HOST}
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    ports:
      - "3306:3306"
    volumes:
      - "mysql-data:/var/lib/mysql"
    networks:
    - attendizenet
  maildev:
    image: djfarrelly/maildev
    ports:
      - "1080:80"
    networks:
      - attendizenet
  redis:
    image: redis
    networks:
      - attendizenet

networks:
  attendizenet:
    driver: bridge

volumes:
    mysql-data: