Skip to content

Commit 2167a58

Browse files
authored
Merge pull request #105 from api3dao/linting-again
Linting again
2 parents fb87437 + b4289cb commit 2167a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3342
-1412
lines changed

.eslintrc.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": [
3+
"plugin:@api3/eslint-plugin-commons/universal",
4+
"next/core-web-vitals"
5+
],
6+
"parserOptions": {
7+
"project": ["./tsconfig.json"]
8+
},
9+
"rules": {
10+
// Some of these can be removed with effort (not addressed by --fix)
11+
"@typescript-eslint/ban-ts-comment": "off",
12+
"@typescript-eslint/no-unsafe-function-type": "off",
13+
"@typescript-eslint/prefer-namespace-keyword": "off",
14+
"@typescript-eslint/prefer-nullish-coalescing": "off",
15+
"eqeqeq": "off",
16+
"functional/no-classes": "off",
17+
"import/no-default-export": "off",
18+
"no-console": "off",
19+
"prefer-named-capture-group": "off",
20+
"prefer-template": "off",
21+
"radix": "off",
22+
"unicorn/filename-case": "off",
23+
"unicorn/no-array-callback-reference": "off",
24+
"unicorn/no-array-push-push": "off",
25+
"unicorn/no-await-expression-member": "off",
26+
"unicorn/number-literal-case": "off",
27+
"unicorn/prefer-code-point": "off",
28+
"unicorn/prefer-string-slice": "off",
29+
"unicorn/prefer-switch": "off"
30+
}
331
}

.github/ISSUE_TEMPLATE/community-bug-bounty.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Community bug bounty
33
about: Submissions for the community bug bounty
4-
title: ''
4+
title: ""
55
labels: cbb
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
## Steps to reproduce

.github/workflows/docker-image.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Continuous Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: "20"
18+
cache: "yarn"
19+
- name: Install dependencies
20+
run: yarn install --frozen-lockfile
21+
- name: Lint
22+
run: yarn lint
23+
24+
only_build:
25+
runs-on: ubuntu-latest
26+
if: github.ref != 'refs/heads/main'
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Build the Docker image
30+
run: docker build . --file Dockerfile --tag api3tracker:latest
31+
32+
build_deploy:
33+
runs-on: ubuntu-latest
34+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
35+
env:
36+
SSH_HOST: ${{ secrets.SSH_HOST }}
37+
SSH_REMOTE_PATH: /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod
38+
steps:
39+
- name: Install SSH Key
40+
uses: shimataro/ssh-key-action@v2
41+
with:
42+
key: ${{ secrets.SSH_PRIVATE_KEY }}
43+
known_hosts: /dev/null
44+
- uses: actions/checkout@v4
45+
- name: Build the Docker image
46+
run: docker build . --file Dockerfile --tag api3tracker:latest
47+
- name: Push main Docker image
48+
run: docker save api3tracker:latest | bzip2 | ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null $SSH_HOST 'bunzip2 -d | docker load'
49+
- name: Apply Terraform plan
50+
run: |
51+
echo "::add-mask::$TF_VAR_API3TRACKER_ENDPOINT"
52+
echo "::add-mask::$TF_VAR_API3TRACKER_ARCHIVE_ENDPOINT"
53+
export REMOTE_CMD="cd $SSH_REMOTE_PATH && terraform init && terraform apply -auto-approve && docker system prune -af"
54+
ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null $SSH_HOST bash -c '"'$REMOTE_CMD'"'

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
FROM node:16.16-alpine3.15 AS dependencies
1+
FROM node:20.18-alpine3.19 AS dependencies
22
WORKDIR /app
33
COPY package.json yarn.lock ./
44
RUN yarn install --frozen-lockfile
55

6-
FROM node:16.16-alpine3.15 AS builder
6+
FROM node:20.18-alpine3.19 AS builder
77
WORKDIR /app
88
COPY . .
99
COPY --from=dependencies /app/node_modules ./node_modules
1010
RUN yarn prisma generate
1111
RUN yarn build
1212
RUN yarn next telemetry disable
1313

14-
FROM node:16.16-alpine3.15
14+
FROM node:20.18-alpine3.19
1515
WORKDIR /app
1616
ENV NODE_ENV=production
1717

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ The services are:
2020
```
2121

2222
Containers:
23+
2324
- api3tracker: The FE and BE-service
2425
- postgres: The database the FE and BE rely on
2526
- traefik: A load balancer that encrypts HTTP responses (using the CF origin server key pair)
2627
- postgres-exporter: a service that exports the database as a backup on an interval
2728

2829
Host services:
2930
The host OS also runs some cron services, these are:
31+
3032
```bash
3133
*/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
3234
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:
3739
```
3840

3941
## Local developement using Docker
42+
4043
Developers can run some or all services locally using Docker Swarm, or even bare-bones, without containerisation.
4144

4245
One combination is running just postgres locally using Docker, eg:
46+
4347
```bash
4448
docker run --rm -ti -p 5432:5432 postgres:15
4549
```
50+
4651
and then running the FE and BE services directly (refer to Cron jobs below and `yarn next dev` in `package.json`).
4752

4853
Alternatively, one can run services using Docker Swarm, but this lacks hot-reloading.
4954

5055
### Local development using Docker Swarm
56+
5157
If you haven't already enabled Swarm mode on your Docker instance, do so now (only has to be done once):
58+
5259
```bash
5360
docker swarm init
5461
```
62+
5563
The result of the above command can be ignored.
5664

5765
Build the FE/BE image:
66+
5867
```bash
5968
docker build -t api3dao/api3-tracker:latest .
6069
```
6170

6271
Run the stack:
72+
6373
```bash
6474
docker stack deploy -c dev-tools/docker-compose.yml tracker-stack
6575
```
6676

6777
If all goes well the application will be served at http://localhost:3000
6878

6979
Some commands for visualising the services:
80+
7081
```bash
7182
docker ps # all docker containers
7283
docker service ls # all swarm services
@@ -75,17 +86,19 @@ docker stack rm tracker-stack # tear down the stack
7586
```
7687

7788
Initialise the DB:
89+
7890
```bash
7991
DATABASE_URL="postgres://postgres:[email protected]:5432/postgres?sslmode=disable" yarn prisma migrate deploy
8092
```
8193

8294
Cron jobs (unwrapped versions of cronjobs):
95+
8396
```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
89102
```
90103

91104
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

Comments
 (0)