Browse Source

Создание репозитория

Vadim Surkov 7 years ago
commit
63361f0466

+ 5 - 0
Dockerfile

@@ -0,0 +1,5 @@
+FROM registry.sdsys.ru/mongo:3.2.10
+ENTRYPOINT ["/init-mongo-rs.sh"]
+COPY init-mongo-rs.sh /init-mongo-rs.sh
+COPY prod /restore/prod/
+RUN chmod +x /init-mongo-rs.sh

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# Mongo-DB-Init #
+
+Сервис первичной инициализации реплсета mongo

+ 14 - 0
dev-build-and-store.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+build_tag="build-$(date +%Y%m%d-%H%M)"
+echo Build tag $build_tag
+
+docker build --no-cache -t mongo-db-init:$build_tag .
+#docker build -t mongo-db-init:$build_tag .
+
+docker tag mongo-db-init:$build_tag dev-registry.infoclinica.ru:5000/iru/mongo-db-init:$build_tag
+docker tag mongo-db-init:$build_tag dev-registry.infoclinica.ru:5000/iru/mongo-db-init:latest
+docker push dev-registry.infoclinica.ru:5000/iru/mongo-db-init:$build_tag
+docker push dev-registry.infoclinica.ru:5000/iru/mongo-db-init:latest

+ 34 - 0
init-mongo-rs.sh

@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+for rs in "$@"; do
+    mongo --host $rs --eval 'db'
+    while [ $? -ne 0 ]; do
+        echo "Waiting for $rs to become available"
+        sleep 3
+        mongo --host $rs --eval 'db'
+    done
+done
+
+mongo --host rs0/$1 --eval 'db.accounts.find( { "username" : "admin" } )' prod | grep ADMIN_GLOBAL > /dev/null
+if [ $? -eq 0 ]; then
+    echo "Replset with database exists"
+    exit 0
+fi
+
+i=0
+for rs in "$@"; do
+    if [ "$rs" != "$1" ]; then
+        MEMBERS="$MEMBERS ,"
+    fi
+    MEMBERS="$MEMBERS {_id: $i, host: \"$rs\" }"
+    i=$((i+1))
+done
+
+mongo --host $1 --eval "rs.initiate({_id: \"rs0\", version: 1, members: [$MEMBERS]})"
+sleep 3
+mongo --host $1 --eval 'rs.status()'
+sleep 10
+
+sleep 30
+cd /restore
+mongorestore --host rs0/$1 .

BIN
prod/[object Object].bson


+ 1 - 0
prod/[object Object].metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.[object Object]"}]}

BIN
prod/accounts.bson


+ 1 - 0
prod/accounts.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.accounts"}]}

BIN
prod/externalSystem.bson


+ 1 - 0
prod/externalSystem.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.externalSystem"}]}

BIN
prod/faqs.bson


+ 1 - 0
prod/faqs.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.faqs"}]}

BIN
prod/fcmTokens.bson


+ 1 - 0
prod/fcmTokens.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.fcmTokens"},{"v":1,"unique":true,"key":{"hostId":1,"notificationId":1},"name":"hostId_1_notificationId_1","ns":"prod.fcmTokens"},{"v":1,"key":{"hostId":1,"tokenInfos.token":1},"name":"hostId_1_tokenInfos.token_1","ns":"prod.fcmTokens"}]}

BIN
prod/fs.chunks.bson


+ 1 - 0
prod/fs.chunks.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.fs.chunks"},{"v":1,"unique":true,"key":{"files_id":1,"n":1},"name":"files_id_1_n_1","ns":"prod.fs.chunks"}]}

BIN
prod/fs.files.bson


+ 1 - 0
prod/fs.files.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.fs.files"},{"v":1,"key":{"filename":1,"uploadDate":1},"name":"filename_1_uploadDate_1","ns":"prod.fs.files"}]}

BIN
prod/hosts.bson


+ 1 - 0
prod/hosts.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.hosts"}]}

BIN
prod/magazines.bson


+ 1 - 0
prod/magazines.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.magazines"}]}

BIN
prod/media.bson


+ 1 - 0
prod/media.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.media"}]}

BIN
prod/nodes.bson


+ 1 - 0
prod/nodes.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.nodes"}]}

BIN
prod/promo.bson


+ 1 - 0
prod/promo.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.promo"}]}

BIN
prod/settings.bson


+ 1 - 0
prod/settings.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.settings"}]}

BIN
prod/system.indexes.bson


BIN
prod/theme.bson


+ 1 - 0
prod/theme.metadata.json

@@ -0,0 +1 @@
+{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"prod.theme"}]}