version: '3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     labels:
       - "traefik.enable=false"
     networks:
       - wp_back
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     labels:
      - "traefik.backend=wp"
      - "traefik.frontend.rule=Host:wp.ichasco.com"
      - "traefik.docker.network=traefik"
     restart: always
     networks:
      - traefik
      - wp_back
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
     volumes:
       - wp_data:/var/www/html

volumes:
    db_data:
    wp_data:

networks:
  wp_back:
    driver: bridge
  traefik:
    external:
      name: traefik

# docker-compose scale wordpress=3
