Browse Source

still working on mongodb authentication

master
Yutsuo 7 years ago
parent
commit
5ef43dac6b
  1. 2
      Dockerfile
  2. 4
      app.js
  3. 5
      db.js
  4. 6
      docker-compose.yml

2
Dockerfile

@ -14,8 +14,6 @@ COPY package.json /app
RUN npm install
COPY . /app
ENV myName="John Doe"
CMD node app.js
EXPOSE 3001

4
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())

5
db.js

@ -1,5 +0,0 @@
// db.js
module.exports = {
DB: 'mongodb://localhost:27017/test'
}

6
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:

Loading…
Cancel
Save