version: "3.9"

services:
  db:
    image: mysql:latest
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: udoit3
      MYSQL_USER: udoit
      MYSQL_PASSWORD: udoit
    ports:
      - "3306:3306"
  # Uncomment this block and comment the next db block
  # to use Postgres instead of MySQL
  # db:
  #   image: postgres:alpine
  #   restart: always
  #   ports:
  #     - "5432:5432"
  #   environment:
  #     POSTGRES_USER: udoit
  #     POSTGRES_PASSWORD: udoit
  #     POSTGRES_DB: udoit3
  web:
      image: nginx:latest
      ports:
        - "8000:80"
      volumes:
        - .:/var/www/html
        - ./build/nginx/local.conf:/etc/nginx/conf.d/default.conf
      links:
          - php
      env_file:
        - .env
  php:
      build:
        context: ./build/nginx
        dockerfile: Dockerfile.php.pdo.mysql
      volumes:
        - ./:/var/www/html
        - type: bind
          source: ./build/nginx/php-custom.ini
          target: /usr/local/etc/php/conf.d/php-custom.ini
      env_file:
        - .env
  composer:
      build:
        context: ./build/nginx
        dockerfile: Dockerfile.composer
      command: "composer install --no-dev --no-interaction --no-progress --optimize-autoloader"
      volumes:
        - ./:/app
      env_file:
        - .env
  yarn:
      image: node:16
      volumes:
        - ./:/app
      env_file:
        - .env
      command: >
        bash -c '
        cd /app &&
        yarn install && 
        yarn build'

volumes:
  web:
  dbdata:
