
Docker Compose for Development: The Setup Every Backend Dev Needs
Docker Compose for Development: The Setup Every Backend Dev Needs You need PostgreSQL, Redis, and your API running locally. Installing each natively leads to version conflicts and "works on my machine" problems. Docker Compose fixes this. Basic Setup # docker-compose.yml services : api : build : . ports : - " 3000:3000" environment : DATABASE_URL : postgres://dev:dev@db:5432/myapp REDIS_URL : redis://cache:6379 depends_on : db : condition : service_healthy cache : condition : service_started volumes : - .:/app - /app/node_modules db : image : postgres:16-alpine environment : POSTGRES_USER : dev POSTGRES_PASSWORD : dev POSTGRES_DB : myapp ports : - " 5432:5432" volumes : - pgdata:/var/lib/postgresql/data healthcheck : test : pg_isready -U dev interval : 5s retries : 5 cache : image : redis:7-alpine ports : - " 6379:6379" volumes : pgdata : Key Patterns Health checks : Use depends_on with condition: service_healthy so your API waits for the database to accept connections, not just start.
Continue reading on Dev.to DevOps
Opens in a new tab




