Skip to content

Commit fb089e8

Browse files
committed
docker example complete
1 parent 41028e3 commit fb089e8

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

assets/docker_example_logs.png

11.4 KB
Loading

examples_new/docker/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,22 @@ For additional details on how Chronos works this example, please review the Dock
3939

4040
Peform the following steps in each of the _Auth_, _Items_, _Inventory_, _Orders_, _Client_, and _Event-Bus_ directories
4141

42-
1. Add a `.env` file to each of _Auth_, _Items_, _Inventory_, _Orders_, _Event-Bus_, and _Client_ folders with the following key/value pairs:
42+
1. Add a `.env` file to each of _Auth_, _Items_, _Inventory_, _Orders_, _Event-Bus_, and _Client_ folders with the following key/value pairs (a `sample.env` file is provided in the `/examples/docker` directory):
4343

4444
- **NOTE**: Ensure that there are no quotes surrounding any of the keys and values.
4545

4646
```
4747
CHRONOS_DB = MongoDB or PostgreSQL
4848
CHRONOS_URI = The URI to the desired MongoDB or PostgreSQL database to save health metrics via Chronos
49-
AUTH_URI = A MongoDB URI for the auth server microservice to use
50-
ITEMS_URI = A MongoDB URI for the items server microservice to use
51-
INVENTORY_URI = A MongoDB URI for the inventory server microservice to use
52-
ORDERS_URI = A MongoDB URI for the orders server microservice to use
5349
CHRONOS_GRAFANA_API_KEY = Bearer [the access token you created in above section (Grafana API Key)]
50+
51+
MONGO_URI_AUTH = A MongoDB URI for the auth server microservice to use
52+
MONGO_URI_ITEMS = A MongoDB URI for the items server microservice to use
53+
MONGO_URI_INVENTORY = A MongoDB URI for the inventory server microservice to use
54+
MONGO_URI_ORDERS = A MongoDB URI for the orders server microservice to use
55+
56+
JWT_KEY = A random string used to sign and verify JSON Web Tokens used by the auth service - the random string provided in **sample.env** will work
57+
JWT_LIFETIME = The time-to-expiration of the JSON Web Token used by the auth service - this is set to `1d` in `sample.env` meaning user authentication is valid for 1 day
5458
```
5559

5660
2. Verify that `@chronosmicro/tracker` is a dependency in each of the _Auth_, _Items_, _Inventory_, _Orders_, and _Event-Bus_ folders (see the `package.json` in each folder).
@@ -65,8 +69,8 @@ CHRONOS_GRAFANA_API_KEY = Bearer [the access token you created in above section
6569
docker-compose -f docker-compose.yml up
6670
```
6771

68-
4. If you run into any issues regarding `linux/amd64,linux/arm/v7,linux/arm64/v8` for cadvisor, navigate to the docker-compose.yml and find the cadvisor dictionary and try the below solutions.
69-
1. Change `platform` to `linux/arm64/v8` for M1 Chips and `linux/amd64` for Intel Chips.
72+
4. If you run into any issues regarding `linux/amd64/v8,linux/arm/v7,linux/arm64/v8` for cadvisor, navigate to the docker-compose.yml and find the cadvisor dictionary and try the below solutions.
73+
1. Change `platform` to `linux/arm64/v8` for M1 Chips and `linux/amd64/v8` for Intel Chips.
7074
1. Change "image" to `image: gcr.io/cadvisor/cadvisor:latest` to `image: gcr.io/cadvisor/cadvisor:v0.47.0`
7175
1. Alternatively, use Docker Buildx to specify multi-platform.
7276

@@ -75,7 +79,7 @@ docker-compose -f docker-compose.yml up
7579
You should now see the containers running in your terminal, each reporting `"docker metrics recorded in..."`.
7680

7781
<p align="center">
78-
<img alt="docker data being recorded" src="../../assets/examples_docker_data.png" width="600" height="100">
82+
<img alt="docker data being recorded" src="../../assets/docker_example_logs.png" width="450">
7983
</p>
8084

8185
If this is being displayed for the `Auth`, `Items`, `Inventory`, `Orders` microservices then the example is successfully saving health metrics to your database of choice!

examples_new/docker/sample.env

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Database type being used to store Chronos metrics
2+
CHRONOS_DB=<MongoDB or Postgres>
3+
# Database connection string for Chronos to write metric to
4+
CHRONOS_URI=<connection string for database to store Chronos metrics>
5+
# the Grafana API Key you created on first startup - see README.md
6+
CHRONOS_GRAFANA_API_KEY=Bearer <your service account token>
7+
8+
# Database connection strings for each microservice
9+
MONGO_URI_AUTH=<connection string for auth service>
10+
MONGO_URI_ITEMS=<connection string for items service>
11+
MONGO_URI_INVENTORY=<connection string for inventory service>
12+
MONGO_URI_ORDERS=<connection string for orders service>
13+
14+
# this is the secret for auth service to sign/verify json web tokens
15+
JWT_KEY=thisStringDoesNotMatterItJustNeedsToBeDefined
16+
# this is time til expiration for the json web token
17+
JWT_LIFETIME=1d

0 commit comments

Comments
 (0)