Docker & Compose fundamentals
Describe the whole stack in one file.
Learn multi-stage Dockerfiles for small production images, and Docker Compose for running a web app, its database, and background workers together, with secrets kept in an env file.
services:
app:
build: .
restart: unless-stopped
env_file: .env # secrets stay out of this file
depends_on: [db]
db:
image: postgres:16-alpine
restart: unless-stopped
env_file: .env
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:Write a docker-compose.yml file that provisions a Node.js web app and PostgreSQL database with persistent volume storage.

