preset Stack web
App + Postgres + Redis
docker-compose · Stack web
Stack applicative classique : service web, Postgres et Redis avec healthchecks.
version: "3.9"
services:
app:
build: .
ports:
- "8000:8000"
environment:
DATABASE_URL: postgresql://app:app@db:5432/app
REDIS_URL: redis://cache:6379/0
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 5s
retries: 10
cache:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redisdata:/data
volumes:
pgdata:
redisdata: