version: '3'

services:
  apache:
    container_name: enthusiast-php7-apache
    image: enthusiast-php7-apache
    build: docker
    ports:
      - 8081:80
      - 9001:9001
    depends_on:
      - mysql
      - mailhog
    links:
      - mysql
    volumes:
      - ./public/enthusiast:/app/public/enthusiast
      - ./public/samplecollective:/app/public/samplecollective
      - ./public/samplefl:/app/public/samplefl
      - ./composer.json:/app/composer.json
      - ./composer.lock:/app/composer.lock
      - ./codeception.yml:/app/codeception.yml
      - ./tests:/app/tests
      - ./docker/samplefl300members:/app/public/samplefl300members:ro
      - ./docker/vhost.conf:/etc/apache2/sites-available/000-default.conf
      - ./docker/configs/config-with-listing-1.php:/app/public/samplefl/config.php:ro
      - ./docker/configs/config-enthusiast-folder.php:/app/public/enthusiast/config.php:ro
      - ./docker/configs/config-without-listing.php:/app/public/config.php:ro
      - ./docker/configs/config-without-listing.php:/app/public/samplecollective/config.php:ro
      - php-vendor:/app/vendor
    environment:
      XDEBUG_CONFIG: "remote_host=192.168.221.1 remote_enable=1 remote_port=9002"
      PHP_IDE_CONFIG: "serverName=Docker"
    networks:
      - internal

  mailhog:
    image: mailhog/mailhog:v1.0.0
    ports:
      - 1025:1025
      - 8025:8025
    networks:
      - internal

  mysql:
    image: mysql:5.7
    command: --default-authentication-plugin=mysql_native_password
    cap_add:
      - SYS_NICE  # CAP_SYS_NICE
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: enth_docker
      MYSQL_USER: enth_docker
      MYSQL_PASSWORD: password
    ports:
      - 13306:3306
    volumes:
      - ./docker/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
    networks:
      - internal

  phpmyadmin:
    depends_on:
      - mysql
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - 8011:80
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: password
    networks:
      - internal

volumes:
  php-vendor:

networks:
  internal:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 192.168.221.0/28
