diff --git a/.env.sample b/.env.sample index 32733b4..bffd9f3 100644 --- a/.env.sample +++ b/.env.sample @@ -4,11 +4,8 @@ SECRET_OAUTH2_SECRET_VERSION=v1 COMPOSE_FILE="compose.yml" -# Set this to run mongodb in replicaset mode (needs initialisation!) -# COMPOSE_FILE="${COMPOSE_FILE}:compose.rs.yml" - -DOMAIN=board.${DOMAIN} -ROOT_URL=https://board.${DOMAIN} +DOMAIN=board.example.org +ROOT_URL=https://board.example.org DEBUG=false diff --git a/README.md b/README.md index 7f374e4..624d723 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,4 @@ needed to enable oplog setting in wekan, which isneeded to run bigger instances? after mongo conaintainer came up the first time run: -``` -abra app run wekan.example.org db mongo -> rs.initiate() -``` \ No newline at end of file +abra app command wekan.example.org db init_db diff --git a/abra.sh b/abra.sh index ba539d4..b9cb142 100644 --- a/abra.sh +++ b/abra.sh @@ -1,2 +1,3 @@ export SECRET_OAUTH2_SECRET_VERSION=v1 export ENTRYPOINT_VERSION=v2 +export INIT_REPLICA_VERSION=v2 diff --git a/backup.db b/backup.db new file mode 100644 index 0000000..ad28e40 Binary files /dev/null and b/backup.db differ diff --git a/compose.rs.yml b/compose.rs.yml deleted file mode 100644 index c9af041..0000000 --- a/compose.rs.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3.8" - -services: - db: - command: mongod --oplogSize 128 --replSet rs0 - - app: - environment: - - MONGO_URL=mongodb://db:27017/wekan?replicaSet=rs01 - - MONGO_OPLOG_URL=mongodb://db:27017/local?replicaSet=rsWekan=value diff --git a/compose.yml b/compose.yml index ffa9cc3..e44673e 100644 --- a/compose.yml +++ b/compose.yml @@ -2,11 +2,15 @@ version: '3.8' services: db: image: mongo:4.4 - command: mongod --oplogSize 128 --replSet rs0 + command: mongod --bind_ip_all --oplogSize 128 --replSet rs0 volumes: - wekan-db:/data/db networks: - internal + configs: + - source: init-replica + target: /docker-entrypoint-initdb.d/init-replica.sh + mode: 0555 healthcheck: test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet interval: 30s @@ -23,8 +27,8 @@ services: app: image: quay.io/wekan/wekan:v6.28 environment: - - MONGO_URL - - MONGO_OPLOG_URL + - MONGO_URL=mongodb://db:27017/wekan?replicaSet=rs0 + - MONGO_OPLOG_URL=mongodb://db:27017/local?replicaSet=rs0 - DOMAIN - ROOT_URL - DEBUG @@ -100,7 +104,9 @@ configs: entrypoint: name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION} file: entrypoint.sh.tmpl - template_driver: golang + init-replica: + name: ${STACK_NAME}_init-replica_${INIT_REPLICA_VERSION} + file: init-replica.sh secrets: oauth2_secret: diff --git a/init-replica.sh b/init-replica.sh new file mode 100644 index 0000000..9792bcf --- /dev/null +++ b/init-replica.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +#host=${HOSTNAME:-$(hostname -f)} +# shut down again +#mongod --pidfilepath /tmp/docker-entrypoint-temp-mongod.pid --shutdown + +# # restart again binding to 0.0.0.0 to allow a replset with 10.7.7.6 +# mongod --oplogSize 8 --replSet rs0 --noauth \ +# --config /tmp/docker-entrypoint-temp-config.json \ +# --bind_ip 0.0.0.0 --port 27017 \ +# --tlsMode disabled \ +# --logpath /proc/1/fd/1 --logappend \ +# --pidfilepath /tmp/docker-entrypoint-temp-mongod.pid --fork + +# init replset with defaults +mongo 0.0.0.0 --eval "rs.initiate()" + +echo "Waiting to become a master" +echo 'while (!db.isMaster().ismaster) { sleep(100); }' | mongo +echo "I'm the master!"