Skip to content

Commit e9bd1fe

Browse files
committed
fix: Update docker-compose file and readme for it
1 parent ba6133a commit e9bd1fe

File tree

11 files changed

+214
-131
lines changed

11 files changed

+214
-131
lines changed

.env.example

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Frontend
2+
NEXT_PUBLIC_API_URL=http://localhost:8000/api
3+
NEXT_PUBLIC_NETWORK_NAME=sanchonet
4+
NEXT_PUBLIC_MANAGER_BASE_DOMAIN=agent_manager:3001
5+
6+
# API and Manager Common
7+
KAFKA_PREFIX=testing
8+
DATABASE_URL=postgresql://root:root@postgres:5432/cardano_autonomous_agent_testing_db
9+
KAFKA_BROKERS=kafka:9093
10+
AGENT_MNEMONIC=
11+
12+
# API
13+
DOCS_URL=/api/docs
14+
KAFKA_ENABLED=true
15+
METADATA_BASE_URL=https://metadata.drep.id/api
16+
DB_SYNC_BASE_URL=http://dbsync:9000/api
17+
18+
# Agent Manager
19+
CLIENT_ID=my-app
20+
CARDANO_NODE_URL=172.31.0.4:3004
21+
KUBER_BASE_URL=https://sanchonet.kuber.cardanoapi.io
22+
KUBER_API_KEY=
23+
MANAGER_WALLET_ADDRESS=
24+
MANAGER_WALLET_SIGNING_KEY=
25+
FAUCET_API_KEY=
26+
CARDANO_NETWORK_MAGIC=4
27+
BLOCKFROST_API_KEY=
28+
ENABLE_BLOCKFROST_SUBMIT_API=True
29+
NETWORK_NAME=sanchonet
30+
31+
# Postgres
32+
POSTGRES_DB=cardano_autonomous_agent_testing_db
33+
POSTGRES_USER=root
34+
POSTGRES_PASSWORD=root
35+
36+
# DbSync
37+
DBSYNC_PORT=9000
38+
DBSYNC_CORS_ENABLE=true
39+
DBSYNC_DATABASE_URL=
40+
41+
# KAFKA
42+
KAFKA_BROKER_ID= 1
43+
KAFKA_ZOOKEEPER_CONNECT= zookeeper:2181
44+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP= DOCKER_NET:PLAINTEXT,HOST_NET:PLAINTEXT
45+
KAFKA_ADVERTISED_LISTENERS= DOCKER_NET://kafka:9093,HOST_NET://localhost:9092
46+
KAFKA_INTER_BROKER_LISTENER_NAME= DOCKER_NET
47+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR= 1
48+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR= 1
49+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR= 1
50+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS= 0
51+
KAFKA_JMX_PORT= 9999
52+
KAFKA_CREATE_TOPICS= "trigger_config_updates:1:1"
53+
54+
#zookeeper
55+
ZOOKEEPER_CLIENT_PORT = 2181
56+
ZOOKEEPER_TICK_TIME = 2000
57+
ZOOKEEPER_SYNC_LIMIT = 2
58+
59+
# Docker network name
60+
DOCKER_NETWORK_NAME=cardano_autonomous_agent
61+
62+
# Docker network name
63+
DOCKER_NETWORK_NAME=cardano_autonomous_agent
64+
65+
# Agent
66+
AGENT_NODE_DOCKER_IMAGE_NAME=autonomous_agent
67+
68+
69+
70+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ app.log
33
.idea/
44
.vscode/
55
*/**/.vscode/
6+
.env
67

78

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ and align with the decentralized governance objectives of Cardano's Voltaire era
2020

2121
### Using Docker
2222

23-
Before running whole service locally using docker you need to add few of the environment variables
24-
on file `docker-compose.dev.yml`
23+
Before running whole service locally using docker you need to create a `.env` and `.env.dbsync` file from `.env.example` and `.env.dbsync.example` respectively to add environment variables.
24+
Below are some of the descriptions of the environment variables.
2525

26-
##### api
27-
- AGENT_MNEMONIC
26+
**Changes to be made in `.env` file**
27+
28+
##### api and manager
29+
- KAFKA_PREFIX
30+
- prefix for kafka topic
31+
- AGENT_MNEMONIC
2832
- Add seed phrase to generate wallet
2933

3034
##### agent_manager
@@ -35,20 +39,27 @@ on file `docker-compose.dev.yml`
3539
- Add a wallet address having sufficient ADA so that it can be used to transfer ADA to agent when requested
3640
- FAUCET_API_KEY (OPTIONAL)
3741
- Add faucet api key to load ADA which will be used to transfer ADA to agents as per request. And it will only be used if the provided `MANAGER_WALLET_ADDRESS` doesnot have sufficient ADA.
38-
- AGENT_MNEMONIC
39-
- Add seed phrase to generate wallet that should be same as added in `api`
4042
- BLOCKFROST_API_KEY (Required if ENABLE_BLOCKFROST_SUBMIT_API is 'True' or enabled)
4143
- Visit [Blockfrost](https://blockfrost.io/) and sign up and generate api key
4244

43-
Note: environment variable `ENABLE_BLOCKFROST_SUBMIT_API` is preferred as if it is not enabled then `Kuber` will be used to submit the transaction which might take couple of minutes.
45+
***Note***: environment variable `ENABLE_BLOCKFROST_SUBMIT_API` is preferred as if it is not enabled then `Kuber` will be used to submit the transaction which might take couple of minutes.
4446

4547
##### dbsync
46-
- DATABASE_URL
48+
- DBSYNC_DATABASE_URL
4749
- Add database url of dbsync
4850

49-
Furthermore all env are setup to run in `Sanchonet` so if you want to run in `Preprod` or `Preview`
51+
##### docker network name
52+
- DOCKER_NETWORK_NAME
53+
- Change name for docker network as default value is provided in `.env.example`
54+
55+
##### agent
56+
- AGENT_NODE_DOCKER_IMAGE_NAME
57+
- Change name for docker network as default value is provided in `.env.example`
58+
59+
***Note***: Furthermore all env are setup to run in `Sanchonet` so if you want to run in `Preprod` or `Preview`
5060
Network then following environment variables are to be updated:
5161

62+
**Changes to be made in `.env` file**
5263
##### frontend
5364
- NEXT_PUBLIC_NETWORK_NAME
5465
- preview or preprod
@@ -73,19 +84,33 @@ Network then following environment variables are to be updated:
7384
- NETWORK_NAME
7485
- preprod or preview
7586

76-
##### dbsync
77-
- DATABASE_URL
87+
##### dbsync
88+
- DBSYNC_DATABASE_URL
7889
- Update the dbsync database url and database name accordingly
7990

91+
92+
Finally run the given command below:
8093
```shell
8194
docker compose -f docker-compose.dev.yml up -d
8295
```
8396

84-
**Note**: You can also use already existing services in place of this
97+
**Note** Make sure no application is running on port `3000`, `8000`
98+
99+
**Note**: After running the above command line, you can run the agent by following steps:
100+
###### For running agent:
101+
- Visit frontend at `http://localhost:3000` and connect your wallet.
102+
- Then click the `My Agent` tab at bottom left. you will be navigated to `Agents Page`
103+
- In `Overview Tab` click `Run Agent` button at the top right of `Agents Overview Section`
104+
- Now copy the docker command and run it in terminal. And Finally your agent is ready to run.
85105

86106

107+
### Setup Locally
108+
87109
The setup guide for each services are in the respective directories:
88110

111+
For running all services locally some of the dependent services like `Kafka`, `Postgresql` can be run via Docker using following command.
112+
113+
89114
1. [Backend](api/README.md)
90115
2. [Agent Manager](agent-manager/README.md)
91116
3. [Agent](agent-node/README.md)

agent-node/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ if (token) {
3232
}
3333
if (!wsUrl) {
3434
const network = token.split('_')[0]
35-
36-
if (network && process.env.MANAGER_BASE_DOMAIN) {
35+
const managerBaseDomain = process.env.MANAGER_BASE_DOMAIN
36+
if (network && managerBaseDomain) {
3737
// This is set in docker file
38-
wsUrl = `wss://${network.toLowerCase()}.${process.env.MANAGER_BASE_DOMAIN}`
39-
} else {
38+
wsUrl = `wss://${network.toLowerCase()}.${managerBaseDomain}`
39+
}
40+
else if (managerBaseDomain){
41+
wsUrl = `ws://${managerBaseDomain}`
42+
}
43+
else {
4044
wsUrl = 'ws://localhost:3001'
4145
}
4246
}

agent-node/src/utils/validator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import { logicalFunctions } from './operatorSupport'
44
const NetworkName = ['preview', 'preprod', 'sanchonet']
55

66
export function validateToken(token: string) {
7-
if (token.split('_').length !== 2) {
7+
if (token.split('_').length < 1) {
88
return 'Not a valid token. Missing secret key'
99
}
1010
if (token.split('_')[1].includes('undefined')) {
1111
return 'Not a valid token. Missing secret key'
1212
}
13-
if (!NetworkName.includes(token.split('_')[0])) return 'Not a valid network name'
1413
return ''
1514
}
1615

0 commit comments

Comments
 (0)