-
Notifications
You must be signed in to change notification settings - Fork 0
/
5-3.txt
123 lines (97 loc) · 1.99 KB
/
5-3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//terminal
// cd notifications-service/
// vi Dockerfile
/* Dockerfile
FROM node:0.12.7
RUN mkdir -p /user/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
EXPOSE 3000
CMD [ "npm", "start" ]
*/
//terminal
// vi server.js
/* server.js
var express = require('express');
var app = expess();
app.get('/notify', function(req, res) {
//Code to sned user an email notification...
console.log('user notified');
res.json({msg: 'user notified'});
});
app.listen(process.env.port || 3000);
*/
// vi server.js
/* server.js
var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var request = require('superagent');
var User = require('./models/User');
var app = express();
app.use(bodyParser.json());
mongoUri = process.env.mongoUri
mongoose.connect(mongoUri);
app.get('/users', function(req, res) {
User.find({}, function(err, users) {
if(err) res.status(500).json({success: false})
else {
res.json(users);
}
});
});
app.post('/users', function(req,res) {
console.log('post /users');
var user = new User(req.body);
user.save(function(err, user) {
if (err) res.status(500).json({success: false})
else {
reques.get('http://notifications/notify', function(response) {
res.json(user);
});
}
});
});
var port = process.env.port || 3000;
app.listen(port, function() {
console.log('server started');
});
*/
//terminal
// vi docker-compose.yml
/* docker-compose.yml
database:
image: mongo
notifications:
build: ./notifications-service
environment:
port: "80"
api:
build: .
volumes:
- .:/usr/src/app
ports:
- "3000:80"
links:
- database
- notifications
environment:
port: "80"
mongoUri: "mongodb://database/app-dev"
*/
//terminal
// docker-compose up
// docker ps
// docker exec -it 3a0a9b353bee /bin/bash
// cat /etc/hosts
// exit
// vi docker-compose.yml
// cd notifications-service/
// vi docker-compose.yml
/* notifications-service/docker-compose.yml
notifications:
build: .
ports:
- "3000:80"
*/