Last active
March 19, 2021 09:09
-
-
Save valentin2105/9c6abe0acc9a05ca0fa3abbf830d80a6 to your computer and use it in GitHub Desktop.
High-Available Wordpress PoC on Docker Swarm 1.12.x with MariaDB Galera cluster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
wordpressPath=/srv/wp01 | |
wordpressName=wordpress01 | |
wordpressPwd=pAssw0rd | |
wordpressUrl=wordpress01.example.com | |
################################## | |
mkdir -p "$wordpressPath"/db | |
mkdir -p "$wordpressPath"/www | |
docker network create --driver=overlay $wordpressName | |
docker service create --name "$wordpressName"-db-cluster \ | |
--network $wordpressName \ | |
--replicas=1 \ | |
--env MYSQL_ROOT_PASSWORD=$wordpressPwd \ | |
--env MYSQL_DATABASE=wordpress \ | |
--env DB_SERVICE_NAME="$wordpressName"-db-cluster \ | |
--mount type=bind,source="$wordpressPath"/db,target=/data \ | |
valentinnc/mariadb-galera:10.1 | |
sleep 2 | |
docker service create --name wordpress01 \ | |
--replicas 1 \ | |
--network $wordpressName \ | |
--network traefik-net \ | |
--label traefik.port=80 \ | |
--label traefik.frontend.rule=Host:"$wordpressUrl" \ | |
-e WORDPRESS_DB_HOST="$wordpressName"-db-cluster \ | |
-e WORDPRESS_DB_PASSWORD=$wordpressPwd \ | |
-e WORDPRESS_DB_USER=root \ | |
--mount type=bind,source="$wordpressPath"/www,target=/var/www/html \ | |
wordpress:latest | |
echo | |
echo "You can scall up services with theses commands :" | |
echo | |
echo "docker service scale "$wordpressName"-db-cluster=3" | |
echo "docker service scale "$wordpressName"=3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker network create --driver=overlay traefik-net | |
docker service create \ | |
--name traefik \ | |
--publish 80:80 --publish 443:443 --publish 8080:8080 \ | |
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ | |
--mount type=bind,source=/srv/traefik/traefik.toml,target=/etc/traefik/traefik.toml \ | |
--network traefik-net \ | |
--mode global \ | |
traefik:v1.1.0-rc1 \ | |
--docker \ | |
--docker.swarmmode \ | |
--docker.domain=example.com \ | |
--docker.watch \ | |
--logLevel=DEBUG \ | |
--web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################ | |
# Web configuration backend | |
################################################################ | |
[web] | |
address = ":8080" | |
################################################################ | |
# Docker configuration backend | |
################################################################ | |
[docker] | |
endpoint = "unix:///var/run/docker.sock" | |
watch = true | |
swarmmode = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This configuration provide a High-available Wordpress using MariaDB Galera Cluster.