Skip to content

Commit c6f8299

Browse files
committed
feat: added a docker compose file to run the indexer with everything needed
1 parent 55e6d23 commit c6f8299

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed

indexer/Dockerfile.development

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
5+
COPY package.json .
6+
RUN yarn install --frozen-lockfile
7+
RUN yarn global add ts-node dotenv-cli
8+
9+
COPY . .
10+
11+
EXPOSE 3001
12+
13+
CMD ["yarn", "dev"]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
version: '3.8'
2+
3+
services:
4+
indexer-db:
5+
image: postgres
6+
container_name: kad-indexer-postgres
7+
environment:
8+
POSTGRES_USER: ${DB_USERNAME}
9+
POSTGRES_PASSWORD: ${DB_PASSWORD}
10+
POSTGRES_DB: ${DB_NAME}
11+
ports:
12+
- "5432:5432"
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME}"]
15+
interval: 10s
16+
timeout: 5s
17+
retries: 5
18+
19+
db-migration:
20+
build:
21+
context: .
22+
dockerfile: Dockerfile.development
23+
container_name: db-migration
24+
environment:
25+
DB_HOST: indexer-db
26+
command: >
27+
/bin/sh -c "
28+
rm -f /app/shared/db-migration-complete &&
29+
rm -f /app/shared/graphql-running &&
30+
yarn create:database &&
31+
touch /app/shared/db-migration-complete"
32+
depends_on:
33+
indexer-db:
34+
condition: service_healthy
35+
volumes:
36+
- shared-data:/app/shared
37+
38+
graphql-app:
39+
build:
40+
context: .
41+
dockerfile: Dockerfile.development
42+
container_name: kad-indexer-graphql
43+
environment:
44+
DB_HOST: indexer-db
45+
command: >
46+
/bin/sh -c "
47+
while [ ! -f /app/shared/db-migration-complete ]; do
48+
echo 'Waiting for db-migration...';
49+
sleep 6;
50+
done &&
51+
touch /app/shared/graphql-running &&
52+
yarn dev:graphql"
53+
ports:
54+
- "3001:3001"
55+
depends_on:
56+
db-migration:
57+
condition: service_started
58+
volumes:
59+
- shared-data:/app/shared
60+
61+
streaming-app:
62+
build:
63+
context: .
64+
dockerfile: Dockerfile.development
65+
container_name: kad-indexer-streaming
66+
environment:
67+
DB_HOST: indexer-db
68+
KADENA_GRAPHQL_API_URL: http://graphql-app
69+
command: >
70+
/bin/sh -c "
71+
while [ ! -f /app/shared/graphql-running ]; do
72+
echo 'Waiting for graphql-app...';
73+
sleep 6;
74+
done &&
75+
yarn dev:streaming"
76+
depends_on:
77+
graphql-app:
78+
condition: service_started
79+
volumes:
80+
- shared-data:/app/shared
81+
82+
volumes:
83+
shared-data:

indexer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
"graphql:generate-types": "npx graphql-codegen",
6666
"dev:database": "ts-node src/index.ts --database",
6767
"dev:streaming": "ts-node src/index.ts --streaming",
68+
"dev:graphql": "ts-node src/index.ts --graphql",
6869
"dev:old-graphql": "ts-node src/index.ts --oldGraphql",
69-
"dev:graphql": "nodemon src/index.ts --graphql",
70-
"dev:guards": "nodemon src/index.ts --guards",
70+
"dev:hot:graphql": "nodemon src/index.ts --graphql",
7171
"prod:start": "docker-compose up --build indexer && docker-compose logs -f indexer",
7272
"prod:streaming": "node dist/index.js --streaming",
7373
"prod:backfill": "node dist/index.js --backfill",

0 commit comments

Comments
 (0)