version: '3.6'

services:

  nginx:
    image: nginx:latest
    container_name: rc-nginx
    ports:
      - '8080:80'
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./src:/var/www/html:rw
    depends_on:
      - wp
    restart: always

  db:
    image: mariadb
    container_name: rc-db
    environment:
      MYSQL_DATABASE: wordpressdb
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    restart: always
    healthcheck:
      test: mysql -h localhost -u wordpress -pwordpress -e"quit" wordpressdb

  wp:
    # image: wordpress:php7.3-fpm-alpine
    build: ./wp
    container_name: rc-wp
    volumes:
      - ./src:/var/www/html:rw
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpressdb
    depends_on:
      - db
    restart: always

  # cli:
  #   image: wordpress:cli-php7.3
  #   container_name: rc-cli
  #   volumes:
  #     - ./src:/var/www/html:rw,cached
  #   environment:
  #     WORDPRESS_DB_HOST: db
  #     WORDPRESS_DB_USER: wordpress
  #     WORDPRESS_DB_PASSWORD: wordpress
  #     WORDPRESS_DB_NAME: wordpressdb
  #   depends_on:
  #     - db
  #   restart: 'no'

  # composer:
  #   image: composer/composer
  #   container_name: rc-composer
  #   working_dir: /var/www/html
  #   restart: 'no'
  #   volumes:
  #     - ./src:/var/www/html:rw,cached

