diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..410343a --- /dev/null +++ b/.env.dist @@ -0,0 +1,12 @@ +COMPOSE_PROJECT_NAME=mongodb +COMPOSE_FILE=compose/mongodb.yml:compose/mongo-express.yml +MONGODB_APN_HOSTNAME=mongo-node.appname + +MONGODB_DATABASE= +MONGODB_USERNAME= +MONGODB_PASSWORD= + +MONGO_EXPRESS_VIRTUAL_HOST=express.mongo.appdomain.com +MONGO_EXPRESS_AUTH_USER= +MONGO_EXPRESS_AUTH_PASS= + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722e17c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +volumes/mongodb diff --git a/compose/mongo-express.yml b/compose/mongo-express.yml new file mode 100644 index 0000000..0e91bac --- /dev/null +++ b/compose/mongo-express.yml @@ -0,0 +1,28 @@ +version: '3.7' + +services: + mongo-express: + image: mongo-express + depends_on: + - mongodb + restart: unless-stopped + expose: + - 8081 + environment: + VIRTUAL_HOST: ${MONGO_EXPRESS_VIRTUAL_HOST} + VIRTUAL_PORT: 8081 + ME_CONFIG_MONGODB_SERVER: "mongodb.compose" + #ME_CONFIG_MONGODB_ADMINUSERNAME: "root" + #ME_CONFIG_MONGODB_ADMINPASSWORD: "${MONGODB_ROOT_PASSWORD}" + ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_AUTH_USER} + ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_AUTH_PASS} + networks: + default: + aliases: + - mongo-express.compose + nginx-proxy: ~ + +networks: + nginx-proxy: + external: true + diff --git a/compose/mongodb.yml b/compose/mongodb.yml new file mode 100644 index 0000000..9a32727 --- /dev/null +++ b/compose/mongodb.yml @@ -0,0 +1,25 @@ +version: '3.7' + +services: + mongodb: + image: 'mongo' + restart: always + labels: + kompose.service.type: nodeport + expose: + - 27017 + volumes: + - ../volumes/mongodb:/data/db + networks: + default: + aliases: + - mongodb.compose + - mongo + application-network: + aliases: + - "${MONGODB_APN_HOSTNAME}" + +networks: + application-network: + external: true + diff --git a/volumes/mongodb/.gitkeep b/volumes/mongodb/.gitkeep new file mode 100644 index 0000000..e69de29