Skip to content

Commit 47a3dd4

Browse files
authored
Merge pull request #6 from iron-fish/rahul/docker-qol-improvements
small quality of life improvements to the docker experience
2 parents 8dce820 + 6f6e2d9 commit 47a3dd4

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

.env.local

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copy this file to .env
2+
# Database Configuration
3+
DB_USER=postgres
4+
DB_PASSWORD=postgres
5+
DB_PORT=5444
6+
7+
# Node Configuration
8+
NODE_HOST=host.docker.internal
9+
NODE_PORT=9092
10+
11+
# Server Configuration
12+
SERVER_PORT=8080
13+
14+
# Security Keys
15+
SECRET_KEY=a0882c5ac5e2fa771dde52b2d5639734a4411df14f4748c6f991a96e5dd9f997
16+
PUBLIC_KEY=03221b2a0ebd9d6798aadee2861a5307ced1a33d143f34c571a98ab4fa534b7d3e

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ PUBLIC_KEY=03221b2a0ebd9d6798aadee2861a5307ced1a33d143f34c571a98ab4fa534b7d3e \
4848
SERVER_PORT=8080 \
4949
docker-compose up
5050
```
51+
52+
Or you can use up with local .env file by copying .env.local to .env:
53+
54+
```bash
55+
cp .env.local .env
56+
docker compose up --build
57+
```
58+
59+
Tips
60+
61+
This came in handy for me because I had a different version of postgres running. To remove all previous data:
62+
```bash
63+
docker compose down -v
64+
```

docker-compose.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '2.4'
22
services:
33
dbconfig:
4+
env_file: .env
45
image: alpine:latest
56
volumes:
67
- conf:/app/conf # Mount the config directory on the host to the container
@@ -14,7 +15,8 @@ services:
1415
protocol: \"postgres\"' > /app/conf/dbconfig"
1516
1617
postgres:
17-
image: postgres:latest
18+
env_file: .env
19+
image: postgres:16
1820
environment:
1921
POSTGRES_USER: ${DB_USER}
2022
POSTGRES_PASSWORD: ${DB_PASSWORD}
@@ -27,11 +29,13 @@ services:
2729
- oreowallet_network
2830
healthcheck:
2931
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
30-
interval: 10s
32+
interval: 5s
3133
timeout: 5s
3234
retries: 5
35+
start_period: 10s
3336

3437
migration:
38+
env_file: .env
3539
build: .
3640
image: "oreowallet"
3741
command: /bin/sh -c "./sqlx database create && ./sqlx migrate run"
@@ -40,23 +44,27 @@ services:
4044
networks:
4145
- oreowallet_network
4246
depends_on:
43-
- postgres
44-
- dbconfig
47+
postgres:
48+
condition: service_healthy
49+
dbconfig:
50+
condition: service_completed_successfully
4551
logging:
4652
driver: "json-file"
4753
options:
4854
max-file: "4"
4955
max-size: "25m"
5056

5157
chainloader:
58+
env_file: .env
5259
build: .
5360
restart: always
5461
image: "oreowallet"
5562
command: ./chain_loader --dbconfig /app/conf/dbconfig --node ${NODE_HOST}:${NODE_PORT} --verbosity ${VERBOSITY:-0}
5663
volumes:
5764
- conf:/app/conf
5865
depends_on:
59-
- migration
66+
migration:
67+
condition: service_completed_successfully
6068
networks:
6169
- oreowallet_network
6270
ulimits:
@@ -70,15 +78,18 @@ services:
7078
max-size: "25m"
7179

7280
prover:
81+
env_file: .env
7382
build: .
7483
restart: always
7584
image: "oreowallet"
7685
command: ./prover --verbosity ${VERBOSITY:-0}
7786
ports:
7887
- "10002:10002"
7988
depends_on:
80-
- migration
81-
- chainloader
89+
migration:
90+
condition: service_completed_successfully
91+
chainloader:
92+
condition: service_completed_successfully
8293
networks:
8394
- oreowallet_network
8495
ulimits:
@@ -92,6 +103,7 @@ services:
92103
max-size: "25m"
93104

94105
server:
106+
env_file: .env
95107
build: .
96108
restart: always
97109
image: "oreowallet"
@@ -121,6 +133,7 @@ services:
121133
max-size: "25m"
122134

123135
dservice:
136+
env_file: .env
124137
build: .
125138
restart: always
126139
image: "oreowallet"
@@ -134,8 +147,10 @@ services:
134147
volumes:
135148
- conf:/app/conf
136149
depends_on:
137-
- migration
138-
- chainloader
150+
migration:
151+
condition: service_completed_successfully
152+
chainloader:
153+
condition: service_completed_successfully
139154
networks:
140155
oreowallet_network:
141156
ipv4_address: 172.19.0.10
@@ -150,14 +165,18 @@ services:
150165
max-size: "25m"
151166

152167
dworker:
168+
env_file: .env
153169
build: .
154170
restart: always
155171
image: "oreowallet"
156172
command: ./dworker --address 172.19.0.10:10001 --verbosity ${VERBOSITY:-0}
157173
depends_on:
158-
- migration
159-
- chainloader
160-
- dservice
174+
migration:
175+
condition: service_completed_successfully
176+
chainloader:
177+
condition: service_completed_successfully
178+
dservice:
179+
condition: service_completed_successfully
161180
networks:
162181
- oreowallet_network
163182
ulimits:

0 commit comments

Comments
 (0)