From 893aa31e4ae69eea6f1c205aa0ff3b8e3d314168 Mon Sep 17 00:00:00 2001 From: Ricky Date: Wed, 3 Jun 2020 10:26:19 -0300 Subject: [PATCH] Docker compose clouseau example --- clouseau-compose/README.md | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 clouseau-compose/README.md diff --git a/clouseau-compose/README.md b/clouseau-compose/README.md new file mode 100644 index 0000000..4fa2892 --- /dev/null +++ b/clouseau-compose/README.md @@ -0,0 +1,94 @@ +standard `docker-compose.yml`. + +```shell +mkdir -p ./config/{couchdb,clouseau} +``` + +**./config/clouseau/clouseau.ini** +```ini +[clouseau] +name=clouseau@127.0.0.1 +cookie=monster +dir=/data +max_indexes_open=500 +``` + +**./config/clouseau/log4j.properties** +``` +log4j.rootLogger=debug, CONSOLE +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %c [%p] %m%n +``` + +**./config/couchdb/local.ini** +```ini +[couch_httpd_auth] +secret = dev + +[admins] +; admin = admin +admin = -pbkdf2-37aa363808ec5b83fc71cf2811479fbf1917f43d,2483e8ffe206819712f3bd1ba2308d41,10 +``` + +```shell +curl -sSL -o clouseau-2.17.0-dist.zip "https://github.com/cloudant-labs/clouseau/releases/download/2.17.0/clouseau-2.17.0-dist.zip +# Unizp clouseau-2.17.0-dist.zip in clouseau-2.17.0 +``` + +**docker-compose.yml** +*This yaml expose 5984 to the host network, if you already using the 5984 change it on the yaml +```yaml +version: '3.8' +services: + couchdb1: + image: couchdb:3.1.0 + restart: always + ports: + - 5984:5984 + environment: + - NODENAME=10.0.0.10 + - ERL_FLAGS=-setcookie monster + volumes: + - ./config/couchdb:/opt/couchdb/etc/local.d + - ./data/couchdb/1:/opt/couchdb/data + networks: + couchdb-net: + ipv4_address: 10.0.0.10 + + clouseau1: + image: openjdk:8 + command: > + java -server + -classpath '/app/*' + -Xmx2G -Dsun.net.inetaddr.ttl=30 + -Dsun.net.inetaddr.negative.ttl=30 + -Dlog4j.configuration=file:/config/log4j.properties + -XX:OnOutOfMemoryError="kill -9 %p" + -XX:+UseConcMarkSweepGC + -XX:+CMSParallelRemarkEnabled com.cloudant.clouseau.Main /config/clouseau.ini + restart: always + depends_on: + - couchdb1 + volumes: + - ./config/clouseau:/config + - ./data/clouseau/1:/data + - ./clouseau-2.17.0:/app + network_mode: service:couchdb1 + +networks: + couchdb-net: + name: couchdb-net + driver: bridge + ipam: + config: + - subnet: 10.0.0.0/24 +``` + +```shell +docker-compose up +``` + +Check it http://127.0.0.1:5984 + +The _trick_ is the `network_mode: service:couchdb1` in the the service `clouseau1`. With this we are telling `clouseau1` service to use the same network of `couchdb1` service. So the ports (4369/epmd) are mapped to the clouseau1 container. For simplicity I just deploy one node, but we can add more easily, join them and deploy a loadbalancer with nginx/haproxy in the same `docker-compose.yml`