Docker
Make sure you have docker and docker-compose installed.
Step 1. Create Dockerfile with the following content:
Python
Assuming you are using poetry for managing the project:
1
FROM python:3.9-slim-buster
2
3
RUN pip install poetry
4
5
WORKDIR /demo
6
COPY poetry.lock pyproject.toml /demo/
7
8
RUN poetry config virtualenvs.create false && poetry install --no-dev
9
10
COPY . /demo
11
12
ENTRYPOINT ["poetry", "run", "dipdup"]
13
CMD ["-c", "dipdup.yml", "run"]
Copied!
Step 2. Create docker-compose.yml with the following sections:
1
version: "3.8"
2
3
services:
4
indexer:
5
build: .
6
depends_on:
7
- db
8
- hasura
9
restart: "no"
10
environment:
11
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
12
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
13
14
db:
15
image: postgres:13
16
restart: always
17
volumes:
18
- db:/var/lib/postgres/data
19
environment:
20
- POSTGRES_USER=dipdup
21
- POSTGRES_DB=dipdup
22
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
23
healthcheck:
24
test: ["CMD-SHELL", "pg_isready -U postgres"]
25
interval: 10s
26
timeout: 5s
27
retries: 5
28
29
hasura:
30
image: hasura/graphql-engine:v2.0.1
31
ports:
32
- 127.0.0.1:42000:8080
33
depends_on:
34
- db
35
restart: always
36
environment:
37
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
38
- HASURA_GRAPHQL_ENABLE_CONSOLE=false
39
- HASURA_GRAPHQL_DEV_MODE=false
40
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
41
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
42
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=user
43
44
volumes:
45
db:
Copied!
Recall that environment variables are expanded in the DipDup config file — in our case we are forwarding Postgres password and Hasura secret.
Step 3. Update dipdup.yml (or create a dedicated config for docker deployment):
1
database:
2
kind: postgres
3
host: db
4
port: 5432
5
user: dipdup
6
password: ${POSTGRES_PASSWORD:-changeme}
7
database: dipdup
8
schema_name: demo
9
10
hasura:
11
url: http://hasura:8080
12
admin_secret: ${ADMIN_SECRET:-changeme}
13
allow_aggregations: False
14
camel_case: true
15
select_limit: 100
Copied!
Note the hostnames (will be resolved in the docker network) and environment variables (will be expanded by DipDup).
Step 4. Build and run the containers:
1
docker-compose up -d --build
Copied!
We recommend lazydocker for monitoring your application.
Last modified 3mo ago
Copy link