services: # ── FastAPI application ────────────────────────────────────────────────── api: build: . # build from the Dockerfile in this directory expose: - "8000" # only expose internally to other containers, NOT to the internet volumes: - notes_data:/app/data # persist notes.db outside the container env_file: - .env environment: - DATABASE_URL=sqlite:////app/data/notes.db # 4 slashes = absolute path in SQLite URL restart: always # auto-restart if the container crashes # ── Nginx reverse proxy ────────────────────────────────────────────────── nginx: image: nginx:alpine # lightweight official Nginx image ports: - "80:80" # expose port 80 to the internet volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf # mount our custom config depends_on: - api # start api container before nginx restart: always # ── Named volume for SQLite data persistence ───────────────────────────── volumes: notes_data: # Docker manages this volume — data survives container rebuilds and restarts # Location on EC2 host: /var/lib/docker/volumes/fastai-notes_notes_data/