version: "3"
services:

  php:
    restart: unless-stopped
    container_name: pravotop-php
    build:
      context: ./docker
      dockerfile: php.Dockerfile
    volumes:
      - ./:/var/www/
    environment:
      - DB_HOST=$DB_HOST
      - DB_DATABASE=$DB_DATABASE
      - DB_USERNAME=$DB_USERNAME
      - DB_PASSWORD=$DB_PASSWORD
      - "REDIS_HOST=redis"
      - "REDIS_PORT=6379"
      - "COMPOSER_MEMORY_LIMIT=-1"
    networks:
      - pravotop
    user: "${UserID:-505}:${GroupID:-505}"

  nginx:
    restart: unless-stopped
    container_name: pravotop-nginx
    image: jguyomard/laravel-nginx:1.13
    volumes:
      - ./:/var/www/
    networks:
      - pravotop

  mysql:
    restart: unless-stopped
    container_name: pravotop-mysql
    build:
      context: ./docker
      dockerfile: mysql.Dockerfile
    volumes:
      - ./docker/db:/var/lib/mysql
      - ./docker/dumps:/docker-entrypoint-initdb.d
    environment:
      - MYSQL_ROOT_PASSWORD=$DB_ROOT
      - MYSQL_DATABASE=$DB_DATABASE
      - MYSQL_USER=$DB_USERNAME
      - MYSQL_PASSWORD=$DB_PASSWORD
    networks:
      - pravotop
    user: "${UserID:-505}:${GroupID:-505}"
    command: [
      '--default_authentication_plugin=mysql_native_password',
      '--character-set-server=utf8mb4',
      '--collation-server=utf8mb4_unicode_ci'
    ]

  redis:
    restart: unless-stopped
    container_name: pravotop-redis
    image: redis:4.0-alpine
    command: redis-server --appendonly yes
    networks:
      - pravotop

  adminer:
    restart: unless-stopped
    image: adminer
    networks:
      - pravotop

  npm:
    networks:
      - pravotop
    image: node:14-buster
    container_name: pravotop-npm
    working_dir: /var/www/
    volumes:
      - ./:/var/www/

networks:
  pravotop:
