@@ -20,13 +20,15 @@ The services are:
20
20
```
21
21
22
22
Containers:
23
+
23
24
- api3tracker: The FE and BE-service
24
25
- postgres: The database the FE and BE rely on
25
26
- traefik: A load balancer that encrypts HTTP responses (using the CF origin server key pair)
26
27
- postgres-exporter: a service that exports the database as a backup on an interval
27
28
28
29
Host services:
29
30
The host OS also runs some cron services, these are:
31
+
30
32
``` bash
31
33
* /10 * * * * root cd /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod && ./bin/job_logs_download.sh >> /var/log/api3-logs-download.log 2>&1
32
34
15,45 * * * * root cd /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod && ./bin/job_supply_download.sh >> /var/log/api3-supply-download.log 2>&1
@@ -37,36 +39,45 @@ The host OS also runs some cron services, these are:
37
39
```
38
40
39
41
## Local developement using Docker
42
+
40
43
Developers can run some or all services locally using Docker Swarm, or even bare-bones, without containerisation.
41
44
42
45
One combination is running just postgres locally using Docker, eg:
46
+
43
47
``` bash
44
48
docker run --rm -ti -p 5432:5432 postgres:15
45
49
```
50
+
46
51
and then running the FE and BE services directly (refer to Cron jobs below and ` yarn next dev ` in ` package.json ` ).
47
52
48
53
Alternatively, one can run services using Docker Swarm, but this lacks hot-reloading.
49
54
50
55
### Local development using Docker Swarm
56
+
51
57
If you haven't already enabled Swarm mode on your Docker instance, do so now (only has to be done once):
58
+
52
59
``` bash
53
60
docker swarm init
54
61
```
62
+
55
63
The result of the above command can be ignored.
56
64
57
65
Build the FE/BE image:
66
+
58
67
``` bash
59
68
docker build -t api3dao/api3-tracker:latest .
60
69
```
61
70
62
71
Run the stack:
72
+
63
73
``` bash
64
74
docker stack deploy -c dev-tools/docker-compose.yml tracker-stack
65
75
```
66
76
67
77
If all goes well the application will be served at http://localhost:3000
68
78
69
79
Some commands for visualising the services:
80
+
70
81
``` bash
71
82
docker ps # all docker containers
72
83
docker service ls # all swarm services
@@ -75,17 +86,19 @@ docker stack rm tracker-stack # tear down the stack
75
86
```
76
87
77
88
Initialise the DB:
89
+
78
90
``` bash
79
91
DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" yarn prisma migrate deploy
80
92
```
81
93
82
94
Cron jobs (unwrapped versions of cronjobs):
95
+
83
96
``` bash
84
- DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts logs download
85
- DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts supply download
86
- DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts treasuries download
87
- DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts shares download
88
- DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" API3TRACKER_ENDPOINT=
" ARCHIVE RPC URL" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts state update --rps-limit
97
+ DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node
-T cli.ts logs download
98
+ DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node
-T cli.ts supply download
99
+ DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node
-T cli.ts treasuries download
100
+ DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node
-T cli.ts shares download
101
+ DATABASE_URL=
" postgres://postgres:[email protected] :5432/postgres?sslmode=disable" API3TRACKER_ENDPOINT=
" ARCHIVE RPC URL" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node
-T cli.ts state update --rps-limit
89
102
```
90
103
91
104
Keep in mind that the Postgres DB in the docker-compose file is not configured with a volume by default, so changes will be lost on service restart.
0 commit comments