Skip to content

Commit a7391a9

Browse files
committed
troubleshoot docker example
1 parent 1a0e758 commit a7391a9

22 files changed

Lines changed: 2012 additions & 34 deletions

File tree

examples_new/docker/auth/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16
1+
FROM node:20-alpine
22
WORKDIR /app
33
COPY . .
44
RUN npm install

examples_new/docker/auth/src/app.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ chronos.propagate();
1616

1717
const app = express();
1818

19-
const trackingMiddleware = chronos.track();
20-
app.use(trackingMiddleware);
21-
2219
app.use(
2320
cors({
2421
credentials: true,
@@ -27,6 +24,7 @@ app.use(
2724
);
2825
app.use(express.json());
2926
app.use(cookieParser());
27+
chronos.docker();
3028

3129
// app.get('/', (req, res) => {
3230
// console.log('💥 Test Route');

examples_new/docker/auth/src/chronos-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ const chronosConfig = {
1111
// Mode Specific
1212
mode: 'docker',
1313
promService: 'docker.for.mac.localhost',
14+
promPort: 9090,
15+
containerName: 'auth',
1416

1517
database: {
1618
connection: 'REST',
1719
type: process.env.CHRONOS_DB,
1820
URI: process.env.CHRONOS_URI,
1921
},
20-
22+
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,
2123
notifications: [],
2224
};
2325
export default chronosConfig;
26+
``

examples_new/docker/client/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ WORKDIR /app
33
COPY . .
44
RUN npm install
55
EXPOSE 5000
6+
EXPOSE 8000
67
CMD ["npm", "run", "dev"]

examples_new/docker/default.conf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
server {
2+
listen 8000;
3+
root /srv/www/static;
4+
location / {
5+
# We try to get static files from nginx first
6+
# because node is not great at IO operations
7+
try_files $uri $uri/ @client;
8+
}
9+
location @client {
10+
proxy_pass http://client:5000;
11+
}
12+
location /api/auth {
13+
proxy_pass http://auth:3000;
14+
}
15+
location /api/items {
16+
proxy_pass http://items:3001;
17+
}
18+
location /api/inventory {
19+
proxy_pass http://inventory:3002;
20+
}
21+
location /api/orders {
22+
proxy_pass http://orders:3003;
23+
}
24+
location /events {
25+
proxy_pass http://event-bus:3005;
26+
}
27+
}
28+
# location /orders/deleteorder:id? {
29+
# proxy_pass http://orders:7777;
30+
# }
31+
# location /orders/getcustomerinfo {
32+
# proxy_pass http://orders:7777;
33+
# }
34+
# location /customers/createcustomer {
35+
# proxy_pass http://customers:5555;
36+
# }
37+
# location /customers/getcustomers {
38+
# proxy_pass http://customers:5555;
39+
# }
40+
# location /customers/deletecustomer:id? {
41+
# proxy_pass http://customers:5555;
42+
# }
43+
# location /customers/getbooksinfo {
44+
# proxy_pass http://customers:5555;
45+
# }
46+
# location /books/createbook {
47+
# proxy_pass http://books:8888;
48+
# }
49+
# location /books/deletebook:id? {
50+
# proxy_pass http://books:8888;
51+
# }
52+
# location /books/getbooks {
53+
# proxy_pass http://books:8888;
54+
# }
55+
# location /books/getordersinfo {
56+
# proxy_pass http://books:8888;
57+
# }
58+
# }

examples_new/docker/docker-compose.yml

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,132 @@ services:
33
auth:
44
build: './auth'
55
#Use image built from the Dockfile in /auth dir
6-
container_name: 'users'
6+
container_name: 'auth'
7+
8+
ports:
9+
- '3000:3000'
10+
11+
volumes:
12+
- '/var/run/docker.sock:/var/run/docker.sock'
13+
client:
14+
build: './client'
15+
#Use image built from the Dockfile in /auth dir
16+
container_name: 'client'
717

818
ports:
919
- '5000:5000'
1020

1121
volumes:
1222
- '/var/run/docker.sock:/var/run/docker.sock'
23+
items:
24+
build: './items'
25+
#Use image built from the Dockfile in /auth dir
26+
container_name: 'items'
27+
28+
ports:
29+
- '3001:3001'
30+
31+
volumes:
32+
- '/var/run/docker.sock:/var/run/docker.sock'
33+
inventory:
34+
build: './inventory'
35+
#Use image built from the Dockfile in /auth dir
36+
container_name: 'inventory'
37+
38+
ports:
39+
- '3002:3002'
40+
41+
volumes:
42+
- '/var/run/docker.sock:/var/run/docker.sock'
43+
orders:
44+
build: './orders'
45+
#Use image built from the Dockfile in /auth dir
46+
container_name: 'orders'
47+
48+
ports:
49+
- '3003:3003'
50+
51+
volumes:
52+
- '/var/run/docker.sock:/var/run/docker.sock'
53+
event-bus:
54+
build: './event-bus'
55+
#Use image built from the Dockfile in /auth dir
56+
container_name: 'event-bus'
57+
58+
ports:
59+
- '3005:3005'
60+
61+
volumes:
62+
- '/var/run/docker.sock:/var/run/docker.sock'
63+
nginx:
64+
# Use latest version of the public nginx image.
65+
image: nginx:latest
66+
67+
container_name: 'production_nginx'
68+
69+
ports:
70+
- '8000:8000'
71+
72+
volumes:
73+
- './client:/srv/www/static'
74+
- './default.conf:/etc/nginx/conf.d/default.conf'
75+
76+
depends_on:
77+
- client
78+
- auth
79+
- items
80+
- inventory
81+
- orders
82+
- event-bus
83+
cadvisor:
84+
image: gcr.io/cadvisor/cadvisor:latest
85+
container_name: cadvisor
86+
privileged: true
87+
# platform: linux/arm64/v8
88+
ports:
89+
- 8081:8081
90+
command:
91+
- '-port=8081'
92+
volumes:
93+
- /:/rootfs:ro
94+
- /etc/machine-id:/etc/machine-id:ro
95+
- /var/run/docker.sock:/var/run/docker.sock:rw
96+
- /sys:/sys:ro
97+
- /var/lib/docker/:/var/lib/docker:ro
98+
depends_on:
99+
- client
100+
- auth
101+
- items
102+
- inventory
103+
- orders
104+
- event-bus
105+
prometheus:
106+
image: prom/prometheus:latest
107+
container_name: prometheus
108+
ports:
109+
- 9090:9090
110+
command:
111+
- --config.file=/etc/prometheus/prometheus.yml
112+
volumes:
113+
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
114+
115+
depends_on:
116+
- cadvisor
117+
118+
grafana:
119+
image: grafana/grafana:latest
120+
container_name: grafana
121+
ports:
122+
- 32000:3000
123+
volumes:
124+
# Share the named volume with the grafana container
125+
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
126+
- ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
127+
environment:
128+
GF_PATHS_CONFIG: /etc/grafana/grafana.ini
129+
GF_SECURITY_ALLOW_EMBEDDING: 'true'
130+
depends_on:
131+
- prometheus
132+
133+
volumes:
134+
grafana-dir: {}

examples_new/docker/event-bus/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16
1+
FROM node:20-alpine
22
WORKDIR /app
33
COPY . .
44
RUN npm install

examples_new/docker/event-bus/src/app.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ chronos.propagate();
1010

1111
const app = express();
1212

13-
const trackingMiddleware = chronos.track();
14-
app.use(trackingMiddleware);
15-
1613
app.use(express.json());
14+
chronos.docker();
1715

1816
app.use('/', async (req: Request, res: Response) => {
1917
// console.log(req.body);

examples_new/docker/event-bus/src/chronos-config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ const chronosConfig = {
99
interval: 5000,
1010

1111
// Mode Specific
12-
mode: 'microservices',
13-
dockerized: false,
12+
mode: 'docker',
13+
promService: 'docker.for.mac.localhost',
14+
promPort: 9090,
15+
containerName: 'event-bus',
1416

1517
database: {
1618
connection: 'REST',
1719
type: process.env.CHRONOS_DB,
1820
URI: process.env.CHRONOS_URI,
1921
},
20-
22+
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,
2123
notifications: [],
2224
};
2325
export default chronosConfig;

0 commit comments

Comments
 (0)