Three assignments. Seven breaking problems. One live production deployment.
Overview
A production-grade Docker Compose stack running The EpicBook โ a Node.js bookstore application โ on AWS EC2, with a proper reverse proxy, healthchecks, named volumes, split networks, structured logging, and environment variable management.
The Journey
The original config used Heroku's database addon string. Fix: rewrote config.json production section to use individual host, username, password fields pointing to the database container by its Docker service name.
Development config had database host set to 127.0.0.1. Inside Docker each container is its own machine. Fix: changed host to "database" โ the service name Docker uses for internal DNS resolution.
Sequelize needed a models folder to define database tables. The folder was not present after cloning. Fix: cloned the original repository into a temp folder and copied the models directory into the project.
Both routes files imported from the wrong path. Fix: used sed to replace the incorrect paths in both files to point to the correct location.
Nginx was loading both a custom nginx.conf and default.conf simultaneously, creating two server blocks on port 80. Fix: updated the Dockerfile to delete default.conf before copying in the custom config.
MySQL remembered the wrong root password from an earlier broken run regardless of environment variables. Fix: ran docker compose down -v to wipe the volume and start completely fresh.
The original schema SQL assumed a database called bookstore. Fix: created the bookstore database manually, granted permissions to the app user, and imported the schema and seed files.
Key Skills
Reduced backend image from ~1.3GB to ~145MB (89% reduction) using a build stage and a lean production stage โ same technique, applied to Node.js instead of React.
Split frontend-network and backend-network so Nginx can reach the backend but cannot reach the database. Defense in depth at the container level.
Made the backend wait for the database to be healthy, and Nginx wait for the backend. Eliminated the race condition that caused random startup failures.
Named volumes for persistent data (MySQL), bind mounts for observability (Nginx logs tailable directly on host without entering any container).
Every error message tells you exactly what is wrong if you read it carefully. 502 Bad Gateway = Nginx cannot reach backend. MODULE_NOT_FOUND = wrong file path. Debugging is not guessing โ it is reading.