version: '3'

networks:
  app-tier:
    driver: bridge

volumes:
  wordpress:

services:
  mariadb:
    container_name: rituximab_mariadb
    image: mariadb
    ports:
      - 5042:3306
    environment:
      - MYSQL_ROOT_PASSWORD=zTB8ZCB3ZWXM8PXX
      - MYSQL_DATABASE=application_database
    networks:
      - app-tier
    volumes:
      - ./.docker/mysql:/var/lib/mysql:delegated
      
  web:
    image: nginx
    container_name: rituximab_web
    ports:
     - 5041:80
    environment:
     - NGINX_ROOT=/var/www
    command: /bin/bash -c "envsubst '$${NGINX_ROOT}' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
    volumes:
      - wordpress:/var/www
      - ./public/wp-content/themes/rituximab:/var/www/wp-content/themes/rituximab:cached
      - ./public/wp-content/uploads:/var/www/wp-content/uploads:delegated
      - ./wp-config.php:/var/www/wp-config.php:cached
      - ./etc/infrastructure/nginx/config/conf.d/default.template:/etc/nginx/conf.d/default.template:cached
      - ./.docker/nginx:/var/log/nginx:delegated
    networks:
      - app-tier
      
  php:
    container_name: rituximab_php
    ports:
      - 5043:3000
    build:
      context: ./etc/infrastructure/php
      dockerfile: Dockerfile
    networks:
      - app-tier
    volumes:
      - wordpress:/var/www
      - ./public/wp-content/themes/rituximab:/var/www/wp-content/themes/rituximab:cached
      - ./public/wp-content/uploads:/var/www/wp-content/uploads:delegated
      - ./wp-config.php:/var/www/wp-config.php:cached