Objective

Deploy a full-stack application with Nginx, app server, database, and cache.

Tools & Technologies

  • Docker Compose
  • Nginx
  • PostgreSQL
  • Redis

Key Commands

docker compose up -d
docker compose exec db psql -U postgres
docker compose scale worker=3
docker compose --profile production up

Lab Steps

01
Architecture

Design a multi-tier application: reverse proxy, app, database, cache.

02
Nginx Reverse Proxy

Configure Nginx to proxy to the application container.

03
Database Container

Connect the application to a PostgreSQL container.

04
Profiles

Use Compose profiles to enable optional services.

Challenges Encountered

  • Database initialization on first run vs restart
  • Nginx upstream DNS resolution timing issues

Key Takeaways

  • Use Docker secrets for sensitive values in production
  • Healthchecks prevent routing to unhealthy containers