Skip to content

Commit 14ff6f5

Browse files
committed
pass env to docker full stack
1 parent d7f3a8a commit 14ff6f5

4 files changed

Lines changed: 22 additions & 31 deletions

File tree

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ SERVER_PORT=8080
99
# =============================================================================
1010
# In Dokploy: Copy the connection string from your PostgreSQL service
1111
# Locally: Use docker-compose db service
12-
DATABASE_URL=postgres://capy:devpassword@localhost:5432/capy_db?sslmode=disable
12+
POSTGRES_USER=capy
13+
POSTGRES_PASSWORD=devpassword
14+
POSTGRES_DB=capy_db
15+
DATABASE_URL=postgres://capy:devpassword@db:5432/capy_db?sslmode=disable
1316

1417
# =============================================================================
1518
# AUTHENTICATION

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,16 @@ To run the full stack (API + Postgres + Cloudflare Tunnel) on a separate machine
188188
services:
189189
db:
190190
image: postgres:16-alpine
191+
env_file:
192+
- .env
191193
environment:
192-
POSTGRES_USER: capy
193-
POSTGRES_PASSWORD: devpassword
194-
POSTGRES_DB: capy_db
195-
ports:
196-
- "5432:5432"
194+
POSTGRES_USER: ${POSTGRES_USER}
195+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
196+
POSTGRES_DB: ${POSTGRES_DB}
197197
volumes:
198198
- pgdata:/var/lib/postgresql/data
199199
healthcheck:
200-
test: [ "CMD-SHELL", "pg_isready -U capy -d capy_db" ]
200+
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
201201
interval: 5s
202202
timeout: 5s
203203
retries: 5
@@ -206,12 +206,8 @@ services:
206206
image: ghcr.io/capy-rpi/api:main
207207
ports:
208208
- "8080:8080"
209-
environment:
210-
DATABASE_URL: postgres://capy:devpassword@db:5432/capy_db?sslmode=disable
211-
JWT_SECRET: your-secret-key
212-
ENV: production
213-
SERVER_HOST: 0.0.0.0
214-
SERVER_PORT: 8080
209+
env_file:
210+
- .env
215211
depends_on:
216212
db:
217213
condition: service_healthy
@@ -220,8 +216,8 @@ services:
220216
image: cloudflare/cloudflared:latest
221217
restart: unless-stopped
222218
command: tunnel run
223-
environment:
224-
- TUNNEL_TOKEN=${TUNNEL_TOKEN}
219+
env_file:
220+
- .env
225221
depends_on:
226222
- api
227223

docker-compose.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
# Local development only - Dokploy handles production
2-
version: "3.9"
3-
41
services:
52
db:
63
image: postgres:16-alpine
4+
env_file:
5+
- .env
76
environment:
8-
POSTGRES_USER: capy
9-
POSTGRES_PASSWORD: devpassword
10-
POSTGRES_DB: capy_db
11-
ports:
12-
- "5432:5432"
7+
POSTGRES_USER: ${POSTGRES_USER}
8+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
9+
POSTGRES_DB: ${POSTGRES_DB}
1310
volumes:
1411
- pgdata:/var/lib/postgresql/data
1512
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql
1613
healthcheck:
17-
test: [ "CMD-SHELL", "pg_isready -U capy -d capy_db" ]
14+
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
1815
interval: 5s
1916
timeout: 5s
2017
retries: 5
@@ -25,9 +22,6 @@ services:
2522
- "8080:8080"
2623
env_file:
2724
- .env
28-
environment:
29-
# Overrides or fallback defaults can go here
30-
DATABASE_URL: postgres://capy:devpassword@db:5432/capy_db?sslmode=disable
3125
depends_on:
3226
db:
3327
condition: service_healthy
@@ -36,8 +30,8 @@ services:
3630
image: cloudflare/cloudflared:latest
3731
restart: unless-stopped
3832
command: tunnel run
39-
environment:
40-
- TUNNEL_TOKEN=${TUNNEL_TOKEN}
33+
env_file:
34+
- .env
4135
depends_on:
4236
- api
4337

todo.md

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

0 commit comments

Comments
 (0)