From 5ef43dac6bd79ad444b6142721d519cb28eb3bfc Mon Sep 17 00:00:00 2001 From: Yutsuo Date: Mon, 19 Nov 2018 23:44:23 +0000 Subject: [PATCH] still working on mongodb authentication --- Dockerfile | 2 -- app.js | 4 ++-- db.js | 5 ----- docker-compose.yml | 6 +++++- 4 files changed, 7 insertions(+), 10 deletions(-) delete mode 100755 db.js diff --git a/Dockerfile b/Dockerfile index 3f2c183..30643eb 100755 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,6 @@ COPY package.json /app RUN npm install COPY . /app -ENV myName="John Doe" - CMD node app.js EXPOSE 3001 diff --git a/app.js b/app.js index 261b473..aec079c 100755 --- a/app.js +++ b/app.js @@ -2,7 +2,7 @@ var express = require('express'); var app = express(); var mongoose = require('mongoose'); var Schema = mongoose.Schema; -var database = 'mongodb://myTester:test@mongo:27017/test'; +var database = 'mongodb://root:ruth@mongo:27017/admin'; var today = new Date(); var counter = 0; var Prometheus = require("prom-client"); @@ -36,7 +36,6 @@ var testSchema = new Schema({ var colors = mongoose.model('colorName', testSchema); // Prometheus metrics -// Handmade app.get('/metrics', function(req, res){ // var now = new Date(); // var passedTime = now - today; @@ -47,6 +46,7 @@ app.get('/metrics', function(req, res){ // res.write('# HELP invocation_count A simple counter for app access during runtime' + '\n'); // res.write('# TYPE invocation_count counter'+ '\n'); // res.write('invocation_count ' + counter + '\n'); + // res.end(); libUptime.inc(Math.floor(process.uptime())); res.set('Content-Type', Prometheus.register.contentType) res.end(Prometheus.register.metrics()) diff --git a/db.js b/db.js deleted file mode 100755 index 6d6be77..0000000 --- a/db.js +++ /dev/null @@ -1,5 +0,0 @@ -// db.js - -module.exports = { - DB: 'mongodb://localhost:27017/test' -} diff --git a/docker-compose.yml b/docker-compose.yml index 3c274b3..8565610 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,11 @@ services: mongo: container_name: mongo image: mongo - command: --auth + environment: + # provide your credentials here + - MONGO_INITDB_ROOT_USERNAME=root + - MONGO_INITDB_ROOT_PASSWORD=ruth + command: mongod ports: - "27017:27017" prometheus: