build: docker compose (app + postgres) with healthchecks and .env

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BwxdSt4reTm7Dj1oxRvpP3
This commit is contained in:
2026-07-04 16:27:16 +07:00
parent 675136e488
commit 77ca0200ae
4 changed files with 153 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
services:
postgres:
image: postgres:17-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-dnsar}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
POSTGRES_DB: ${POSTGRES_DB:-dnsar}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-dnsar} -d ${POSTGRES_DB:-dnsar}"]
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped
app:
build: .
depends_on:
postgres:
condition: service_healthy
environment:
DNS_AR_DB_DSN: postgres://${POSTGRES_USER:-dnsar}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-dnsar}?sslmode=disable
DNS_AR_ENC_KEY: ${DNS_AR_ENC_KEY:?base64 32 bytes, see .env.example}
DNS_AR_LISTEN: ":8080"
ports:
- "${APP_PORT:-8080}:8080"
healthcheck:
test: ["CMD", "/app", "-healthcheck"]
interval: 10s
timeout: 4s
retries: 5
start_period: 15s
restart: unless-stopped
volumes:
pgdata: