services:
  db:
    image: mysql:8.0
    restart: unless-stopped
    container_name: ${DATABASE_CONTAINER_NAME}
    env_file:
      - path: ./wordpress.env
        required: true
      - path: ../global.env
        required: true
    environment:
      MYSQL_DATABASE: ${MYSQL_DB_NAME}
      MYSQL_USER: ${MYSQL_DB_USER}
      MYSQL_PASSWORD: ${MYSQL_DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${MYSQL_DB_PASSWORD}
    volumes:
      - ${HOME_DIR}/${STACK_NAME}/${DATABASE_CONTAINER_NAME}:/var/lib/mysql
  wordpress:
    depends_on:
      - ${DATABASE_CONTAINER_NAME}
    ports:
      - ${PORT_HTTP}:80
    image: wordpress
    restart: unless-stopped
    container_name: ${WORDPRESS_CONTAINER_NAME}
    env_file:
      - path: ./wordpress.env
        required: true
      - path: ../global.env
        required: true
    extra_hosts:
      ${WORDPRESS_HOSTNAME}: "127.0.1.1"
    environment:
      VIRTUAL_HOST: ${WORDPRESS_HOSTNAME}
      WORDPRESS_DB_HOST: ${DATABASE_CONTAINER_NAME}
      WORDPRESS_DB_USER: ${MYSQL_DB_USER}
      WORDPRESS_DB_PASSWORD: ${MYSQL_DB_PASSWORD}
      WORDPRESS_DB_NAME: ${MYSQL_DB_NAME}
    volumes:
      - ${HOME_DIR}/${STACK_NAME}/${WORDPRESS_CONTAINER_NAME}:/var/www/html
