We all have that one commit we’re not proud of. You know, the one pushed late on a Friday night with the message: "pls work".
For me, that commit contained my very first Dockerfile. I was fresh out of a tutorial, convinced I had mastered containerization. Spoiler: I had not.
Looking back at that file is like looking at a mullet haircut from 1987. It was functional, but messy, insecure, and bloated.
Let me show you the evolution. The cringe vs. the clean. The Before vs. the After.
The "Before": The Wild West Dockerfile
I was building a simple Node.js API. My logic was: Install everything, copy everything, run everything as root, and pray.
dockerfile
Before: The "It works on my machine" special
FROM node:latest
Create app directory (Good start, but wait for it...)
WORKDIR /usr/src/app
Copy EVERYTHING. Node modules? Yeah, copy those too. .git? Sure.
COPY .…