ecos-mongo-app
Purpose:
Image for deploying a MongoDB container with preconfigured datasource settings for microservices
Base images:
mongo_4 - Official mongodb v 4.0.x image
Docker Compose service template:
mongo-app:
logging:
options:
max-size: "10m"
max-file: "5"
container_name: mongo-app
hostname: mongo-app
restart: unless-stopped
stop_grace_period: 1m
image: nexus.citeck.ru/mongo:4.0
env_file:
- ./env_dir/mongo-app.env
expose:
- 27017/tcp
volumes:
- /opt/mongo-app:/data/db/
networks:
- app_network
Used variables:
MONGO_INITDB_ROOT_USERNAME - login of the user to be created in admin db with root privileges
MONGO_INITDB_ROOT_PASSWORD - privileged user password
MONGO_INITDB_DATABASE - definition of the database used in deployment scripts in
/docker-entrypoint-initdb.d/*.js/sh. (1)ECOS_HISTORY_APP_DATASOURCE_DATABASE - database of the history microservice (ecos-history)
ECOS_HISTORY_APP_DATASOURCE_USERNAME - login for the history microservice, dbOwner role (ecos-history)
ECOS_HISTORY_APP_DATASOURCE_PASSWORD - password for the history microservice (ecos-history-password)
ECOS_PROCESS_APP_DATASOURCE_DATABASE - database of the ecos-process microservice (ecos-process)
ECOS_PROCESS_APP_DATASOURCE_USERNAME - login for the ecos-process microservice, dbOwner role (ecos-process)
ECOS_PROCESS_APP_DATASOURCE_PASSWORD - password for the ecos-process microservice (ecos-process-password)
This variable allows you to specify the name of a database to be used for creation scripts in /docker-entrypoint-initdb.d/.js (see Initializing a fresh instance below). MongoDB is fundamentally designed for «create on first use», so if you do not insert data with your JavaScript files, then no database is created.
Typical log output for successful deployment:
MongoDB shell version v4.0.18
connecting to: mongodb://127.0.0.1:27017/test?gssapiServiceName=mongodb
2020-05-06T07:44:13.565+0000 I NETWORK [listener] connection accepted from 127.0.0.1:42378 #3 (1 connection now open)
2020-05-06T07:44:13.565+0000 I NETWORK [conn3] received client metadata from 127.0.0.1:42378 conn3: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.18" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
Implicit session: session { "id" : UUID("3cb7f158-dfaa-4ffd-896f-b36052828f19") }
MongoDB server version: 4.0.18
2020-05-06T07:44:13.593+0000 I ACCESS [conn3] Successfully authenticated as principal root_user on admin from client 127.0.0.1:42378
1
ecos-process
Successfully added user: {
"user" : "ecos-process",
"roles" : [
{
"role" : "dbOwner",
"db" : "ecos-process"
}
]
}
ecos-history
Successfully added user: {
"user" : "ecos-history",
"roles" : [
{
"role" : "dbOwner",
"db" : "ecos-history"
}
]
}
bye