# docker-compose up -d --scale wordpress=3 --scale db=2

version: '3'

services:
   wpdb:
     image: mysql:5.7
     volumes:
       - wpdb:/var/lib/mysql
     restart: unless-stopped
     labels:
       - traefik.enable=false
     networks:
       - wp_back
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - wpdb
     image: wordpress:latest
     labels:
      - "traefik.enable=true"
      - "traefik.port=80"
      - "traefik.backend=wordpress"
      - "traefik.frontend.rule=Host:wp.${SERV}"
  #    - "traefik.frontend.rule=Host:${SERV}; PathPrefix:/wp"
  #    - "traefik.frontend.rule=PathPrefixStrip:/wp"
      - "traefik.docker.network=traefik"
     restart: unless-stopped
 #    ports:
 #      - "80:80"
     networks:
      - traefik
      - wp_back
     environment:
       WORDPRESS_DB_HOST: wpdb:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
     volumes:
       - wp:/var/www/html
     deploy:
       mode: replicated
       replicas: 2
       restart_policy:
         condition: always
       labels: 
         APP: WORDPRESS

volumes:
    wpdb:
    wp:

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

# docker-compose scale wordpress=3

