version: '3'

networks:
  laravel:

services:
  site:
    build:
      context: .
      dockerfile: ./.docker/nginx.dockerfile
    container_name: nginx
    ports:
      - 8006:80
    volumes:
      - ./:/var/www/html:delegated
    depends_on:
      - php
      # - redis
      - mysql
      # - mailhog
    networks:
      - laravel

  mysql:
    image: mysql:5.7.29
    container_name: mysql
    restart: unless-stopped
    tty: true
    ports:
      - 4306:3306
    volumes:
      - ./.docker/mysql:/var/lib/mysql
    environment:
      MYSQL_DATABASE: com
      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    networks:
      - laravel

  php:
    build:
      context: .
      dockerfile: ./.docker/php.dockerfile
    container_name: php
    volumes:
      - ./:/var/www/html:delegated
    networks:
      - laravel

  # redis:
  #   image: redis:alpine
  #   container_name: redis
  #   restart: unless-stopped
  #   ports:
  #     - 6379:6379
  #   networks:
  #     - laravel

  composer:
    build:
      context: .
      dockerfile: ./.docker/composer.dockerfile
    container_name: composer
    volumes:
      - ./:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    user: laravel
    entrypoint: ['composer', '--ignore-platform-reqs']
    # entrypoint: ['composer']
    networks:
      - laravel

  npm:
    image: node:13.7
    container_name: npm
    volumes:
      - ./:/var/www/html
    working_dir: /var/www/html
    entrypoint: ['npm']
    networks:
      - laravel

  artisan:
    build:
      context: .
      dockerfile: ./.docker/php.dockerfile
    container_name: artisan
    volumes:
      - ./:/var/www/html:delegated
    depends_on:
      - mysql
    working_dir: /var/www/html
    user: laravel
    entrypoint: ['php', '/var/www/html/artisan']
    networks:
      - laravel

  # mailhog:
  #   image: mailhog/mailhog:latest
  #   container_name: mailhog
  #   ports:
  #     - 1025:1025
  #     - 8025:8025
  #   networks:
  #     - laravel
