127.0.0.1:3000 only accepted connections from localhost. DB port intentionally stays on 127.0.0.1. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.5 KiB
YAML
56 lines
1.5 KiB
YAML
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "127.0.0.1:5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
app:
|
|
build: .
|
|
ports:
|
|
- "0.0.0.0:3000:3000"
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
|
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
|
|
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3000}
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# First-run setup: applies the schema and seeds the user.
|
|
# Uses the builder stage so all dev tools (prisma CLI, tsx, bcryptjs) are available.
|
|
# Run once with: docker compose --profile setup run --rm setup
|
|
setup:
|
|
build:
|
|
context: .
|
|
target: builder
|
|
command: sh -c "npx prisma db push && npx prisma db seed"
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
|
SEED_EMAIL: ${SEED_EMAIL}
|
|
SEED_PASSWORD: ${SEED_PASSWORD}
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
profiles:
|
|
- setup
|
|
|
|
volumes:
|
|
postgres_data:
|