Skip to content

Commit 244dbb0

Browse files
m-kusdroserasprout
andauthored
Explicit env vars, fix integer overflows (#23)
Co-authored-by: Lev Gorodetskiy <[email protected]>
1 parent 86c8303 commit 244dbb0

File tree

8 files changed

+65
-46
lines changed

8 files changed

+65
-46
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ scripts
99
tests
1010
*.ipynb
1111
*.json
12-
*.zip
12+
*.zip
13+
docker-compose.yml
14+
Dockerfile

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ USER dipdup
2323

2424
WORKDIR /home/dipdup/
2525
EXPOSE 8888
26-
ENTRYPOINT [ "python", "-m", "dipdup"]
26+
ENTRYPOINT ["python", "-m", "dipdup"]
27+
CMD ["-c", "dipdup.yml", "run"]

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,8 @@ Use `docker-compose.yml` included in this repo if you prefer to run dipdup in Do
178178

179179
```shell
180180
$ docker-compose build
181-
$ cp secrets.env.example secrets.env
182-
$ # edit `secrets.env` file, change credentials
183-
$ docker-compose up dipdup
181+
$ # example target, edit volumes section to change dipdup config
182+
$ docker-compose up hic_et_nunc
184183
```
185184

186185
For debugging purposes you can index specific block range only and skip realtime indexing. To do this set `first_block` and `last_block` fields in index config.

docker-compose.yml

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
11
version: "3.8"
22

3-
x-dipdup: &x-dipdup
4-
build: .
5-
depends_on:
6-
- db
7-
volumes:
8-
- ./src/demo_hic_et_nunc/dipdup-docker.yml:/home/dipdup/dipdup.yml
9-
env_file: secrets.env
10-
113
services:
12-
dipdup:
13-
<<: *x-dipdup
4+
hic_et_nunc:
5+
build: .
6+
depends_on:
7+
- db
8+
volumes:
9+
- ./src/demo_hic_et_nunc/dipdup-docker.yml:/home/dipdup/dipdup.yml
1410
restart: always
15-
command: ["-c", "dipdup.yml", "run"]
11+
environment:
12+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
13+
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
14+
15+
# quipuswap:
16+
# build: .
17+
# depends_on:
18+
# - db
19+
# volumes:
20+
# - ./src/demo_quipuswap/dipdup-docker.yml:/home/dipdup/dipdup.yml
21+
# restart: always
22+
# environment:
23+
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
24+
# - ADMIN_SECRET=${ADMIN_SECRET:-changeme}
25+
26+
tzcolors:
27+
build: .
1628
depends_on:
1729
- db
30+
volumes:
31+
- ./src/demo_tzcolors/dipdup-docker.yml:/home/dipdup/dipdup.yml
32+
restart: always
33+
environment:
34+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
35+
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
1836

1937
db:
2038
image: postgres
2139
restart: always
2240
volumes:
2341
- db:/var/lib/postgres/data
24-
env_file: secrets.env
42+
environment:
43+
- POSTGRES_USER=dipdup
44+
- POSTGRES_DB=dipdup
45+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
2546
healthcheck:
2647
test: ["CMD-SHELL", "pg_isready -U postgres"]
2748
interval: 10s
@@ -31,11 +52,16 @@ services:
3152
hasura:
3253
image: hasura/graphql-engine:v1.3.3
3354
ports:
34-
- 8080:8080
55+
- 127.0.0.1:8080:8080
3556
depends_on:
36-
- db
57+
- db
3758
restart: always
38-
env_file: secrets.env
59+
environment:
60+
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
61+
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
62+
- HASURA_GRAPHQL_DEV_MODE=true
63+
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
64+
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
3965

4066
volumes:
4167
db:

secrets.env.example

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

src/demo_hic_et_nunc/dipdup-docker.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ database:
55
kind: postgres
66
host: db
77
port: 5432
8-
user: dipdup
9-
password: changeme
10-
database: dipdup
8+
user: ${POSTGRES_USER:-dipdup}
9+
password: ${POSTGRES_PASSWORD:-changeme}
10+
database: ${POSTGRES_DB:-dipdup}
1111
schema_name: hic_et_nunc
1212

1313
hasura:
1414
url: http://hasura:8080
15-
admin_secret: changeme
15+
admin_secret: ${ADMIN_SECRET:-changeme}
1616

1717
contracts:
1818
HEN_objkts:

src/demo_hic_et_nunc/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ class Holder(Model):
1919
class Token(Model):
2020
id = fields.BigIntField(pk=True)
2121
creator = fields.ForeignKeyField('models.Holder', 'tokens')
22-
supply = fields.IntField()
22+
supply = fields.BigIntField()
2323
level = fields.BigIntField()
2424
timestamp = fields.DatetimeField()
2525

2626

2727
class Swap(Model):
2828
id = fields.BigIntField(pk=True)
2929
creator = fields.ForeignKeyField('models.Holder', 'swaps')
30-
price = fields.IntField()
31-
amount = fields.IntField()
32-
amount_left = fields.IntField()
30+
price = fields.BigIntField()
31+
amount = fields.BigIntField()
32+
amount_left = fields.BigIntField()
3333
level = fields.BigIntField()
3434
status = fields.IntEnumField(SwapStatus)
3535
timestamp = fields.DatetimeField()

src/demo_tzcolors/models.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Meta:
1616

1717

1818
class Token(Model):
19-
id = fields.IntField(pk=True)
19+
id = fields.BigIntField(pk=True)
2020
address = fields.CharField(59)
21-
amount = fields.IntField()
22-
level = fields.IntField()
21+
amount = fields.BigIntField()
22+
level = fields.BigIntField()
2323
timestamp = fields.DatetimeField()
2424
holder = fields.ForeignKeyField('models.Address', 'tokens')
2525

@@ -28,24 +28,24 @@ class Meta:
2828

2929

3030
class Auction(Model):
31-
id = fields.IntField(pk=True)
31+
id = fields.BigIntField(pk=True)
3232
token = fields.ForeignKeyField('models.Token', 'auctions')
33-
bid_amount = fields.IntField()
33+
bid_amount = fields.BigIntField()
3434
bidder = fields.ForeignKeyField('models.Address', 'winning_auctions')
3535
seller = fields.ForeignKeyField('models.Address', 'created_auctions')
3636
end_timestamp = fields.DatetimeField()
3737
status = fields.IntEnumField(AuctionStatus)
38-
level = fields.IntField()
38+
level = fields.BigIntField()
3939
timestamp = fields.DatetimeField()
4040

4141
class Meta:
4242
table = 'auctions'
4343

4444

4545
class Bid(Model):
46-
id = fields.IntField(pk=True)
46+
id = fields.BigIntField(pk=True)
4747
auction = fields.ForeignKeyField('models.Auction', 'bids')
48-
bid_amount = fields.IntField()
48+
bid_amount = fields.BigIntField()
4949
bidder = fields.ForeignKeyField('models.Address', 'bids')
50-
level = fields.IntField()
50+
level = fields.BigIntField()
5151
timestamp = fields.DatetimeField()

0 commit comments

Comments
 (0)