Skip to content

Commit 5738504

Browse files
committed
Revised docker-compose files
Signed-off-by: Alexander Pyatakov <[email protected]>
1 parent 901a512 commit 5738504

10 files changed

+1058
-313
lines changed

.env.template

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
## GUARDIAN ECOSYSTEM ENVIRONMENT NAME
2-
# if you already started to use actively Guardian leave GUARDIAN_ENV empty when you want to use it as usual
3-
# if you want to use a new environment configure GUARDIAN_ENV with a significative environment name
4-
GUARDIAN_ENV=""
1+
# GUARDIAN ECOSYSTEM ENVIRONMENT NAME
2+
# if you have already started actively using Guardian, leave GUARDIAN_ENV blank if you want to continue use it as normal
3+
# if you want to use a new environment, configure GUARDIAN_ENV with a meaningful environment name
4+
GUARDIAN_ENV=
5+
6+
# GUARDIAN_VERSION
7+
# This variable specifies the version tag for Guardian services images.
8+
# It is used for multiple services in Docker Compose configurations without the "-build" postfix.
9+
#
10+
# Usage:
11+
# - Set to a specific version number for reproducible builds (e.g., "2.27.1")
12+
# - Leave empty to use the default version specified in the Docker Compose file
13+
#
14+
# Examples:
15+
# GUARDIAN_VERSION=2.27.1
16+
# GUARDIAN_VERSION=latest
17+
# GUARDIAN_VERSION=
18+
#
19+
# Note: If not set, it defaults to "latest" in the Docker Compose file.
20+
GUARDIAN_VERSION=

README.md

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Guardian is a modular open-source solution that includes best-in-class identity
1111
## Discovering Digital Environmental Assets assets on Hedera
1212

1313

14-
As identified in Hedera Improvement Proposal 19 (HIP-19), each entity on the Hedera network may contain a specific identifier in the memo field for discoverability. Guardian demonstrates this when every Hedera Consensus Service transaction is logged to a Hedera Consensus Service (HCS) Topic. Observing the Hedera Consensus Service Topic, you can discover newly minted tokens.
14+
As identified in Hedera Improvement Proposal 19 (HIP-19), each entity on the Hedera network may contain a specific identifier in the memo field for discoverability. Guardian demonstrates this when every Hedera Consensus Service transaction is logged to a Hedera Consensus Service (HCS) Topic. Observing the Hedera Consensus Service Topic, you can discover newly minted tokens.
1515

1616
In the memo field of each token mint transaction you will find a unique Hedera message timestamp. This message contains the url of the Verifiable Presentation (VP) associated with the token. The VP can serve as a starting point from which you can traverse the entire sequence of documents produced by Guardian policy workflow, which led to the creation of the token. This includes a digital Methodology (Policy) HCS Topic, an associated Registry HCS Topic for that Policy, and a Project HCS Topic.
1717

@@ -73,7 +73,7 @@ For this example purpose let's name the Guardian platform as "develop"
7373
GUARDIAN_ENV="develop"
7474
```
7575

76-
> **_NOTE:_** Every single service is provided in its folder with a `.env.template` file, this set of files are only needed for the case of Manual installation.
76+
> **_NOTE:_** Every single service is provided in its folder with a `.env.template` file, this set of files are only needed for the case of Manual installation.
7777
7878
#### 3. Update BC access variables.
7979

@@ -87,7 +87,7 @@ There will be other steps in the Demo Usage Guide that will be required for the
8787
The parameter `HEDERA_NET` may assume the following values: `mainnet`, `testnet`, `previewnet`, `localnode`. choose the right value depending on your target Hedera network on which the `OPERATOR_ID` has been defined.
8888

8989
As examples:
90-
90+
9191
following the previous example, the file to configure should be named: `./configs/.env.develop.guardian.system`, this file is already provided in the folder as an example, only update the variables OPERATOR_ID, OPERATOR_KEY and HEDERA_NET.
9292

9393
```plaintext
@@ -97,7 +97,7 @@ The parameter `HEDERA_NET` may assume the following values: `mainnet`, `testnet`
9797
```
9898

9999
Starting from Multi-environment release (2.13.0) it has been introduced a new parameter `PREUSED_HEDERA_NET`.
100-
Multienvironemnt is a breaking change and the configuration of this parameter intend to smooth the upgrading.
100+
Multienvironemnt is a breaking change and the configuration of this parameter intend to smooth the upgrading.
101101
`PREUSED_HEDERA_NET` configuration depends on the installation context.
102102

103103
- If the installation is a completely new one just remove the parameter and feel free to jump to the next paragraph.
@@ -107,15 +107,15 @@ Multienvironemnt is a breaking change and the configuration of this parameter in
107107
##### 3.1. PREUSED_HEDERA_NET configuration
108108

109109
The `PREUSED_HEDERA_NET` parameter is intended to hold the target Hedera network that the system already started to notarize data to. PREUSED\_HEDERA\_NET is the reference to the HEDERA_NET that was in use before the upgrade.
110-
To let the Multi-environment transition happen in a transparent way the `GUARDIAN_ENV` parameter in the `.env` file has to be configured as empty while the `PREUSED_HEDERA_NET` has to be set with the same value configured in the `HEDERA_NET` parameter in the previous configuration file.
110+
To let the Multi-environment transition happen in a transparent way the `GUARDIAN_ENV` parameter in the `.env` file has to be configured as empty while the `PREUSED_HEDERA_NET` has to be set with the same value configured in the `HEDERA_NET` parameter in the previous configuration file.
111111

112112
`PREUSED_HEDERA_NET` never needs to be changed after the first initialization. On the contrary it will be possible to change `HEDERA_NET` to dials with all the Hedera different networks.
113113

114-
- as first Example:
114+
- as first Example:
115115

116116
in case of the upgrading from a release minor then 2.13.0 to a bigger one and keep using the same HEDERA_NET="Mainnet"(as example)
117117

118-
configure the name the Guardian platform as empty in the `.env` file
118+
configure the name the Guardian platform as empty in the `.env` file
119119

120120
```shell
121121
GUARDIAN_ENV=""
@@ -138,7 +138,7 @@ To let the Multi-environment transition happen in a transparent way the `GUARDIA
138138

139139
- As a second example: to test the new release change the HEDERA_NET to "testnet". This is the complete configuration:
140140

141-
Set the name of the Guardian platform to whatever descripting name in the `.env` file
141+
Set the name of the Guardian platform to whatever descripting name in the `.env` file
142142

143143
```shell
144144
GUARDIAN_ENV="testupgrading"
@@ -158,7 +158,7 @@ To let the Multi-environment transition happen in a transparent way the `GUARDIA
158158
PREUSED_HEDERA_NET="mainnet"
159159
```
160160

161-
This configuration allows you to leave untouched all the data referring to Mainnet in the Database while testing on Testnet. Refer to Guardian
161+
This configuration allows you to leave untouched all the data referring to Mainnet in the Database while testing on Testnet. Refer to Guardian
162162
[documentation](https://docs.hedera.com/guardian/guardian/readme/environments/multi-session-consistency-according-to-environment) for more details.
163163

164164
> **_NOTE:_** You can use the Schema Topic ID (`INITIALIZATION_TOPIC_ID`) already present in the configuration files, or you can specify your own.
@@ -185,25 +185,25 @@ To let the Multi-environment transition happen in a transparent way the `GUARDIA
185185
To select this option ensure that `IPFS_PROVIDER="web3storage"` setting exists in your `./configs/.env.<environment>.guardian.system` file.
186186

187187
To configure access to the [w3up](https://github.com/web3-storage/w3up) IPFS upload API from web3.storage for your Guardian instance you need to set correct values to the following variables in the `./configs/.env.<environment>.guardian.system` file:
188-
188+
189189
```
190190
IPFS_STORAGE_KEY="..."
191191
IPFS_STORAGE_PROOF="..."
192192
```
193193

194194
> **_NOTE:_** When Windows OS is used for creating the IPFS values, please use bash shell to prevent issues with base64 encoding.
195-
195+
196196
To obtain the values for these variables please follow the steps below:
197197
- Create an account on https://web3.storage, please specify the email you have access to as the account authentication is based on the email validation. Make sure to follow through the registration process to the end, choose an appropriate billing plan for your needs (e.g. 'starter') and enter your payment details.
198198
- Install w3cli as described in the [corresponding section](https://web3.storage/docs/w3cli/#install) of the web3.storage documentation.
199199
- Create your 'space' as described in the ['Create your first space'](https://web3.storage/docs/w3cli/#create-your-first-space) section of the documentation.
200-
- Execute the following to set the Space you intend on delegating access to:
200+
- Execute the following to set the Space you intend on delegating access to:
201201
`w3 space use`.
202-
- Execute the following command to retrieve your Agent private key and DID:
203-
`npx ucan-key ed`.
202+
- Execute the following command to retrieve your Agent private key and DID:
203+
`npx ucan-key ed`.
204204
The private key (starting with `Mg...`) is the value to be used in the environment variable `IPFS_STORAGE_KEY`.
205205
- Retrieve the PROOF by executing the following:
206-
```w3 delegation create <did_from_ucan-key_command_above> | base64```.
206+
```w3 delegation create <did_from_ucan-key_command_above> | base64```.
207207
The output of this command is the value to be used in the environment variable `IPFS_STORAGE_PROOF`.
208208

209209
To summarise, the process of configuring delegated access to the w3up API consists of execution the following command sequence:
@@ -230,7 +230,7 @@ configuration.
230230

231231
For detailed setup instructions, refer to the
232232
official <https://docs.filebase.com/api-documentation/ipfs-pinning-service-api>.
233-
233+
234234
#### 5. Setting up Chat GPT API KEY to enable AI Search and Guided Search:
235235

236236
For setting up AI and Guided Search, we need to set OPENAI_API_KEY variable in `./configs/.env*` files.
@@ -239,13 +239,40 @@ For setting up AI and Guided Search, we need to set OPENAI_API_KEY variable in `
239239
OPENAI_API_KEY="..."
240240
```
241241

242-
#### 6. Build and launch with Docker. Please note that this build is meant to be used in production and will not contain any debug information. From the project's root folder:
242+
#### 6. Build and launch with Docker.
243243

244-
```shell
245-
docker compose up -d --build
246-
```
247-
248-
> **_NOTE:_** About docker-compose: from the end of June 2023 Compose V1 won’t be supported anymore and will be removed from all Docker Desktop versions. Make sure you use Docker Compose V2 (comes with Docker Desktop > 3.6.0) as at https://docs.docker.com/compose/install/
244+
The following list outlines various Docker Compose configurations for different purposes. Choose the one that best suits your needs.
245+
246+
| Configuration | Description | Command to Run |
247+
|---------------|-------------|----------------|
248+
| Guardian (Demo Mode) | Guardian using pre-built images | `docker-compose up -d --build` |
249+
| Guardian Build (Demo Mode) | Builds Guardian from source code | `docker-compose -f docker-compose-build.yml up -d --build` |
250+
| Production Guardian | Guardian using pre-built images, no demo mode | `docker-compose -f docker-compose-production.yml up -d --build` |
251+
| Production Guardian Build | Builds Guardian from source code, no demo mode | `docker-compose -f docker-compose-production-build.yml up -d --build` |
252+
| Indexer | Indexer using pre-built images | `docker-compose -f docker-compose-indexer.yml up -d --build` |
253+
| Indexer Build | Builds Indexer from source code | `docker-compose -f docker-compose-indexer-build.yml up -d --build` |
254+
| Analytics Service | Analytics Service using pre-built images | `docker-compose -f docker-compose-analytics.yml up -d --build` |
255+
| Analytics Service Build | Builds Analytics Service from source code | `docker-compose -f docker-compose-analytics-build.yml up -d --build` |
256+
257+
To proceed:
258+
259+
1. Choose the configuration that matches your requirements.
260+
2. Open a terminal in the project root folder.
261+
3. Run the corresponding command from the "Command to Run" column.
262+
263+
For example, to run the standard Guardian in demo mode:
264+
265+
```shell
266+
docker-compose up -d --build
267+
```
268+
269+
This will start the containers in detached mode (-d) and build them if necessary.
270+
271+
> **_NOTE:_** Configurations with "Build" in their name compile the application from source code, which may take longer but allows for customization.
272+
273+
> **_NOTE:_** Production configurations do not include demo features and will not contain any debug information.
274+
275+
> **_NOTE:_** From the end of June 2023 Compose V1 won’t be supported anymore and will be removed from all Docker Desktop versions. Make sure you use Docker Compose V2 (comes with Docker Desktop > 3.6.0) as at https://docs.docker.com/compose/install/
249276
250277
#### 7. Browse to <http://localhost:3000> and complete the setup.
251278

@@ -272,9 +299,9 @@ If you want to manually build every component with debug information, then build
272299

273300
Install, configure and start all the prerequisites, then build and start each component.
274301

275-
#### Services Configuration:
302+
#### Services Configuration:
276303

277-
- for each of the services create the file `./<service_name>/.env` to do this copy, paste and rename the file `./<service_name>/.env.template`
304+
- for each of the services create the file `./<service_name>/.env` to do this copy, paste and rename the file `./<service_name>/.env.template`
278305

279306
For example:
280307

@@ -285,11 +312,11 @@ Install, configure and start all the prerequisites, then build and start each co
285312

286313
If need to configure OVERRIDE uncomment the variable in file `./guardian-service/.env`:
287314
```plaintext
288-
OVERRIDE="false"
315+
OVERRIDE="false"
289316
```
290317

291-
- configure the file `./<service_name>/configs/.env.<service>.<GUARDIAN_ENV>` file: to do this copy,
292-
paste and rename the file `./<service_name>/.env.<service>.template`
318+
- configure the file `./<service_name>/configs/.env.<service>.<GUARDIAN_ENV>` file: to do this copy,
319+
paste and rename the file `./<service_name>/.env.<service>.template`
293320

294321
following previous example:
295322

@@ -321,7 +348,7 @@ For setting up AI and Guided Search, we need to set OPENAI_API_KEY variable in `
321348
Npm:
322349
```
323350
npm install
324-
```
351+
```
325352
#### 3. From the **interfaces** folder
326353

327354
Yarn:
@@ -399,7 +426,7 @@ For setting up AI and Guided Search, we need to set OPENAI_API_KEY variable in `
399426
```
400427
npm --workspace=auth-service start
401428
```
402-
429+
403430
#### 7. From the **policy-service** folder
404431

405432
To build the service:
@@ -425,7 +452,7 @@ For setting up AI and Guided Search, we need to set OPENAI_API_KEY variable in `
425452
Npm:
426453
```
427454
npm --workspace=policy-service start
428-
```
455+
```
429456
#### 8. Build and start **worker-service** service
430457

431458
Yarn:
@@ -617,11 +644,11 @@ npm --workspace=ai-service start
617644
```
618645
VAULT_PROVIDER = "hashicorp"
619646
```
620-
647+
621648
Note: VAULT_PROVIDER can be set to "database" or "hashicorp" to select Database instance or a hashicorp vault instance correspondingly.
622-
623-
If the VAULT_PROVIDER value is set to "hashicorp" the following 3 parameters should be configured in the auth-service folder.
624-
649+
650+
If the VAULT_PROVIDER value is set to "hashicorp" the following 3 parameters should be configured in the auth-service folder.
651+
625652
1. HASHICORP_ADDRESS : http://localhost:8200 for using local vault. For remote vault, we need to use the value from the configuration settings of Hashicorp vault service.
626653
2. HASHICORP_TOKEN : the token from the Hashicorp vault.
627654
3. HASHICORP_WORKSPACE : this is only needed when we are using cloud vault for Hashicorp. Default value is "admin".
@@ -630,18 +657,18 @@ npm --workspace=ai-service start
630657
1. OPERATOR_ID
631658
2. OPERATOR_KEY
632659
3. IPFS_STORAGE_API_KEY
633-
660+
634661
Note: These records in the vault will be created automatically if there are environment variables with the matching names.
635-
662+
636663
**How to import existing user keys from DB into the vault:**
637-
664+
638665
During Guardian services initialization, we need to set the following configuration settings in **auth-service** folder:
639-
666+
640667
```
641668
IMPORT_KEYS_FROM_DB = 1
642669
VAULT_PROVIDER = "hashicorp"
643670
```
644-
671+
645672
## Local development using Docker
646673

647674
#### 1. create .env file at the root level and update all variable requires for docker
@@ -679,7 +706,7 @@ npm --workspace=ai-service start
679706
To run **guardian-service** unit tests, following commands needs to be executed:
680707

681708
```shell
682-
cd guardian-service
709+
cd guardian-service
683710
npm run test
684711
```
685712

docker-compose-analytics-build.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# https://docs.docker.com/compose/environment-variables/envvars-precedence/
2+
# Environment leverage the gerarchy defined in the docker compose between "env_file" and "environment" attributes
3+
# ecosystem variables defined in the "env_file" .env.${GUARDIAN_ENV}.guardian.system
4+
# specific service variables defined by "environment" can override what is defined in the ecosystem file
5+
6+
# YAML anchor that contains common configuration elements for our services
7+
x-service-template: &service-template
8+
init: true
9+
env_file:
10+
- ./configs/.env.${GUARDIAN_ENV}.guardian.system
11+
environment:
12+
- GUARDIAN_ENV=${GUARDIAN_ENV}
13+
14+
services:
15+
mongo:
16+
image: mongo:6.0.16
17+
command: "--setParameter allowDiskUseByDefault=true"
18+
restart: always
19+
expose:
20+
- 27017
21+
22+
message-broker:
23+
image: nats:2.9.25
24+
expose:
25+
- 4222
26+
ports:
27+
- '8222:8222'
28+
command: '-c /etc/nats/nats.conf --http_port 8222'
29+
volumes:
30+
- ./configs/nats.conf:/etc/nats/nats.conf
31+
32+
logger-service:
33+
<<: *service-template
34+
build:
35+
context: .
36+
dockerfile: ./logger-service/Dockerfile
37+
depends_on:
38+
- message-broker
39+
volumes:
40+
- ./logger-service/configs:/usr/local/app/configs:ro
41+
42+
auth-service:
43+
<<: *service-template
44+
build:
45+
context: .
46+
dockerfile: ./auth-service/Dockerfile
47+
volumes:
48+
- ./auth-service/tls:/usr/local/app/tls:ro
49+
- ./auth-service/configs:/usr/local/app/configs:ro
50+
depends_on:
51+
- mongo
52+
- message-broker
53+
- logger-service
54+
expose:
55+
- 6555
56+
- 5005
57+
58+
queue-service:
59+
<<: *service-template
60+
build:
61+
context: .
62+
dockerfile: ./queue-service/Dockerfile
63+
depends_on:
64+
- mongo
65+
- message-broker
66+
expose:
67+
- 6555
68+
volumes:
69+
- ./queue-service/configs:/usr/local/app/configs:ro
70+
71+
worker-service:
72+
<<: *service-template
73+
build:
74+
context: .
75+
dockerfile: ./worker-service/Dockerfile
76+
depends_on:
77+
queue-service:
78+
condition: service_started
79+
auth-service:
80+
condition: service_started
81+
expose:
82+
- 6555
83+
volumes:
84+
- ./worker-service/tls:/usr/local/app/tls:ro
85+
- ./worker-service/configs:/usr/local/app/configs:ro
86+
deploy:
87+
replicas: 10
88+
89+
analytics-service:
90+
<<: *service-template
91+
build:
92+
context: .
93+
dockerfile: ./analytics-service/Dockerfile
94+
depends_on:
95+
- message-broker
96+
- queue-service
97+
expose:
98+
- 6555
99+
ports:
100+
- "3000:3020"
101+
volumes:
102+
- ./analytics-service/configs:/usr/local/app/configs:ro
103+
104+
networks:
105+
monitoring:
106+
driver: bridge

0 commit comments

Comments
 (0)