Skip to content

Commit a6558a8

Browse files
authored
Merge pull request #11 from Kettailor/codex/enable-auto-update-for-docker-images
Enable live reload for services in Docker
2 parents 3bd4477 + 61a37ba commit a6558a8

File tree

9 files changed

+46
-5
lines changed

9 files changed

+46
-5
lines changed

api-gateway/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const httpProxy = require("http-proxy");
44
const proxy = httpProxy.createProxyServer();
55
const app = express();
66

7+
app.use((req, res, next) => {
8+
console.log(`[API Gateway][Docker] ${req.method} ${req.originalUrl}`);
9+
next();
10+
});
11+
712
const AUTH_SERVICE_HOST = process.env.AUTH_SERVICE_HOST || "auth";
813
const AUTH_SERVICE_PORT = process.env.AUTH_SERVICE_PORT || "3000";
914
const PRODUCT_SERVICE_HOST = process.env.PRODUCT_SERVICE_HOST || "product";

api-gateway/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "node index.js"
8+
"start": "node index.js",
9+
"dev": "node --watch index.js"
910
},
1011
"keywords": [],
1112
"author": "",

auth/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha --timeout 20000 src/test/**/*.test.js --exit",
8-
"start": "node index.js"
8+
"start": "node index.js",
9+
"dev": "node --watch index.js"
910
},
1011
"keywords": [],
1112
"author": "",

auth/src/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class App {
2929
setMiddlewares() {
3030
this.app.use(express.json());
3131
this.app.use(express.urlencoded({ extended: false }));
32+
this.app.use((req, res, next) => {
33+
console.log(
34+
`[Auth Service][Docker] ${req.method} ${req.originalUrl}`
35+
);
36+
next();
37+
});
3238
}
3339

3440
setRoutes() {

docker-compose.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ services:
2525
- auth/.env
2626
ports:
2727
- "3000:3000"
28+
volumes:
29+
- ./auth:/usr/src/app
30+
- /usr/src/app/node_modules
31+
command: npm run dev
2832
depends_on:
2933
- mongo
3034

@@ -34,17 +38,25 @@ services:
3438
- product/.env
3539
ports:
3640
- "3001:3001"
41+
volumes:
42+
- ./product:/usr/src/app
43+
- /usr/src/app/node_modules
44+
command: npm run dev
3745
depends_on:
3846
- mongo
3947
- rabbitmq
40-
48+
4149

4250
order:
4351
build: ./order
4452
env_file:
4553
- order/.env
4654
ports:
4755
- "3002:3002"
56+
volumes:
57+
- ./order:/usr/src/app
58+
- /usr/src/app/node_modules
59+
command: npm run dev
4860
depends_on:
4961
- mongo
5062
- rabbitmq
@@ -53,6 +65,10 @@ services:
5365
build: ./api-gateway
5466
ports:
5567
- "3003:3003"
68+
volumes:
69+
- ./api-gateway:/usr/src/app
70+
- /usr/src/app/node_modules
71+
command: npm run dev
5672
depends_on:
5773
- auth
5874
- product

order/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "node index.js"
8+
"start": "node index.js",
9+
"dev": "node --watch index.js"
910
},
1011
"keywords": [],
1112
"author": "",

order/src/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const config = require("./config");
77
class App {
88
constructor() {
99
this.app = express();
10+
this.app.use((req, res, next) => {
11+
console.log(`[Order Service][Docker] ${req.method} ${req.originalUrl}`);
12+
next();
13+
});
1014
this.connectDB();
1115
this.setupOrderConsumer();
1216
}

product/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "app.js",
66
"scripts": {
77
"test": "mocha --timeout 20000 src/test/**/*.test.js --exit",
8-
"start": "node index.js"
8+
"start": "node index.js",
9+
"dev": "node --watch index.js"
910
},
1011
"keywords": [],
1112
"author": "",

product/src/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class App {
3030
setMiddlewares() {
3131
this.app.use(express.json());
3232
this.app.use(express.urlencoded({ extended: false }));
33+
this.app.use((req, res, next) => {
34+
console.log(
35+
`[Product Service][Docker] ${req.method} ${req.originalUrl}`
36+
);
37+
next();
38+
});
3339
}
3440

3541
setRoutes() {

0 commit comments

Comments
 (0)