version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - ${CUSTOM_PORT}:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: ${CUSTOM_USER}
      WORDPRESS_DB_PASSWORD: ${CUSTOM_PASSWORD}
      WORDPRESS_DB_NAME: ${CUSTOM_DATABASE}
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql
    restart: always
    environment:
      MYSQL_DATABASE: ${CUSTOM_DATABASE}
      MYSQL_USER: ${CUSTOM_USER}
      MYSQL_PASSWORD: ${CUSTOM_PASSWORD}
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db: