Browse Source

struggling with mongodb image

master
Yutsuo 7 years ago
parent
commit
ff0b4019e6
  1. 18
      docker-compose.yml
  2. 5
      mongo/Dockerfile
  3. 10
      mongo/dbusersetup.js
  4. 0
      node/Dockerfile
  5. 3
      node/app.js
  6. 0
      node/package.json
  7. 7
      org_cheat_sheet

18
docker-compose.yml

@ -1,26 +1,25 @@
version: "3"
version: '3'
services:
app:
container_name: app
depends_on:
- mongo
restart: always
build: .
build: ./node
image: custom/node
ports:
- "3001:3001"
- '3001:3001'
links:
- mongo
mongo:
container_name: mongo
image: mongo
build: ./mongo
image: custom/mongo
environment:
# provide your credentials here
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=ruth
command: mongod
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: ruth
ports:
- "27017:27017"
- 27017:27017
prometheus:
container_name: prometheus
image: prom/prometheus:latest
@ -33,7 +32,6 @@ services:
image: grafana/grafana
ports:
- 3000:3000
# configuration below to set subnet in order to function within BB network.
networks:
default:
ipam:

5
mongo/Dockerfile

@ -0,0 +1,5 @@
FROM mongo
COPY dbusersetup.js /docker-entrypoint-initdb.d
EXPOSE 27017

10
mongo/dbusersetup.js

@ -0,0 +1,10 @@
// create test user
use test
db.createUser(
{
user: "myTester",
pwd: "test",
roles: [ { role: "readWrite", db: "test" },
{ role: "read", db: "reporting" } ]
}
)

0
Dockerfile → node/Dockerfile

3
app.js → node/app.js

@ -13,13 +13,12 @@ const libCounter = new Prometheus.Counter({
});
const libUptime = new Prometheus.Counter({
name: 'lib_upTime',
name: 'lib_upTime',
help: 'uptime A counter of the application\'s uptime in seconds.'
})
// const collectDefaultMetrics = Prometheus.collectDefaultMetrics;
// Probe every 5th second.
// collectDefaultMetrics({ timeout: 5000 });

0
package.json → node/package.json

7
org_cheat_sheet

@ -69,3 +69,10 @@ db.createUser(
exit
// logging in as new user
mongo -u "myTester" -p "test" --authenticationDatabase "test"
// git :: reset local with remote
git fetch
git reset --hard origin/master
// mongodb env vars don't get setup if container is already running
// https://github.com/docker-library/mongo/issues/174#issuecomment-297538188

Loading…
Cancel
Save