Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose clouseau example #182

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions clouseau-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
standard `docker-compose.yml`.

```shell
mkdir -p ./config/{couchdb,clouseau}
```

**./config/clouseau/clouseau.ini**
```ini
[clouseau]
[email protected]
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`