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: services:
app: app:
container_name: app container_name: app
depends_on: depends_on:
- mongo - mongo
restart: always restart: always
build: . build: ./node
image: custom/node image: custom/node
ports: ports:
- "3001:3001" - '3001:3001'
links: links:
- mongo - mongo
mongo: mongo:
container_name: mongo container_name: mongo
image: mongo build: ./mongo
image: custom/mongo
environment: environment:
# provide your credentials here MONGO_INITDB_ROOT_USERNAME: root
- MONGO_INITDB_ROOT_USERNAME=root MONGO_INITDB_ROOT_PASSWORD: ruth
- MONGO_INITDB_ROOT_PASSWORD=ruth
command: mongod
ports: ports:
- "27017:27017" - 27017:27017
prometheus: prometheus:
container_name: prometheus container_name: prometheus
image: prom/prometheus:latest image: prom/prometheus:latest
@ -33,7 +32,6 @@ services:
image: grafana/grafana image: grafana/grafana
ports: ports:
- 3000:3000 - 3000:3000
# configuration below to set subnet in order to function within BB network.
networks: networks:
default: default:
ipam: 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({ const libUptime = new Prometheus.Counter({
name: 'lib_upTime', name: 'lib_upTime',
help: 'uptime A counter of the application\'s uptime in seconds.' help: 'uptime A counter of the application\'s uptime in seconds.'
}) })
// const collectDefaultMetrics = Prometheus.collectDefaultMetrics; // const collectDefaultMetrics = Prometheus.collectDefaultMetrics;
// Probe every 5th second. // Probe every 5th second.
// collectDefaultMetrics({ timeout: 5000 }); // collectDefaultMetrics({ timeout: 5000 });

0
package.json → node/package.json

7
org_cheat_sheet

@ -69,3 +69,10 @@ db.createUser(
exit exit
// logging in as new user // logging in as new user
mongo -u "myTester" -p "test" --authenticationDatabase "test" 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