Today I learned about Multi-Stage Builds in Docker — and honestly, this is one of the coolest ways to reduce image size and keep #Dockerfiles clean. Instead of building and running everything in a single image, we can use multiple stages: • Stage 1 → Build the application • Stage 2 → Use a lightweight image to run it • Copy only the required build output Example idea: • Use node image to install dependencies & build • Use nginx:alpine to serve only the final build • Copy /app/build from builder stage • Final image becomes smaller, faster, and more secure Why Multi-Stage Builds are useful: • Smaller Docker image size • No dev dependencies in production • Better security • Cleaner Dockerfile • Faster deployments This is the pattern I explored today: Stage 1 → Build Stage 2 → Runtime (nginx) Copy only what is needed #Docker #DevOps #Containers #SoftwareEngineering #LearningInPublic #Backend #NodeJS #Nginx
Ayush Gupta’s Post
More Relevant Posts
-
I wasted hours on slow Docker builds before I understood one thing: Layer order is everything. Here's a visual that finally made it click for me 👇 When you run docker build, Docker executes each Dockerfile instruction and saves the result as an immutable snapshot — a layer. Change something early in the file? Every layer after it rebuilds. No cache. No shortcuts. This is why the "right" Dockerfile pattern looks like this: 1. FROM base image 2. COPY package.json (just the manifest) 3. RUN npm install ← cached unless deps change 4. COPY . . ← your source code 5. RUN npm build If you flip steps 2 and 4, every code change triggers a full npm install. On a large project that's minutes, not seconds. I built an interactive layer visualizer to make this tangible — link in comments. What's the Docker mistake you wish someone had shown you earlier? #Docker #DockerTips #Dockerfile #DevOps #CloudNative #WebDevelopment #SoftwareEngineering #BuildInPublic #LearningInPublic #NodeJS #FrontendDev #ReactJS
To view or add a comment, sign in
-
🚀 Reduced My Docker Image Size by More Than 50% — Here’s How Recently, I optimized one of my Node.js backend Docker images and the results were pretty solid. 📦 Before optimization: ~200MB ⚡ After optimization: ~90MB That’s more than 50% reduction — which directly improves build time, push/pull speed, and deployment efficiency. Here’s what made the difference: ✅ Used .dockerignore to exclude unnecessary files (huge impact) ✅ Installed only production dependencies with npm ci --omit=dev ✅ Improved Docker layer caching by copying package.json first ✅ Cleaned up unnecessary cache files ✅ Applied multi-stage build to remove build-time dependencies 💡 Key takeaway: Optimizing Docker images is not just about size — it’s about faster CI/CD pipelines, better scalability, and cleaner production environments. If you're working with Node.js and not optimizing your Docker images yet, you're leaving performance on the table. Next step for me: pushing this setup into a full CI/CD pipeline with automated builds and deployments. #Docker #DevOps #NodeJS #FullStackDevelopment #CI_CD #SoftwareEngineering
To view or add a comment, sign in
-
-
Most projects stop at “it works on my machine.” This one doesn’t. I built a simple full-stack application — but focused on how it actually runs in a real environment. Here’s what’s inside: • Frontend served via Nginx (containerized) • Backend API built with Node.js (Express) • Separate containers for each service • Docker Compose used to run everything together Instead of mixing everything in one setup, the application is split into services — just like real systems. How it flows: User → Frontend (Nginx) → Backend API → JSON Response No complexity for the sake of it. Just a clean setup that shows how services talk to each other. What this project helped me understand better: • How containers isolate services • How frontend and backend communicate in a containerized setup • Why multi-container architecture matters • How Docker Compose simplifies orchestration This is a small project, but it reflects a mindset shift: From writing code → to thinking about deployment. GitHub: https://lnkd.in/gctxFU4Z #Docker #DevOps #NodeJS #Nginx #FullStack #DockerCompose
To view or add a comment, sign in
-
-
One of the first real challenges I had with Docker was containerizing a Node.js application. At a glance, it looks simple: Write a Dockerfile, build the image, run the container. But in practice, the details matter a lot more than they seem. I ran into issues early on - and most of them came down to the fundamentals: - Choosing the right base image - Understanding the working directory - Copying files from the correct context - Knowing exactly what each line in the Dockerfile is doing At one point, the container would build successfully, but the application wouldn’t run as expected. That’s usually where the real understanding starts. Instead of just writing Docker files, I had to start thinking in terms of: - Where the app lives inside the container - What dependencies it needs to run - How everything is structured and copied Once I paid attention to those details, things became much more predictable. Docker is simple at a high level, but getting it right comes down to understanding how each piece fits together. #Docker #Containers #CloudComputing #DevOps #NodeJS #TechCommunity #TheEmpatheticEngineer
To view or add a comment, sign in
-
-
Set up a CI/CD pipeline for my Express + TypeScript backend today and hit two small gotchas worth sharing. When you wire GitHub Actions to deploy to Render via a deploy hook, you have to remember to turn off Render's auto-deploy first. Otherwise both fire on every merge — Render watching the push, Actions firing the hook — and you get duplicate deploys racing each other. Also worth knowing: if you make the Deploy job a required status check on PRs, you'll lock yourself out of merging. The deploy job is gated to only run on push-to-main, not on pull request events, so it shows as "skipped" on every PR — and skipped doesn't count as passed. Two things that took me longer to figure out than I'd like to admit. Sharing in case it saves someone else the same detour. #GitHubActions #CICD #DevOps #NodeJS
To view or add a comment, sign in
-
-
REST vs GraphQL — after using both in production: Here’s the honest take 👇 REST: ✔ Simple ✔ Easy caching ✔ Great for standard CRUD GraphQL: ✔ Flexible queries ✔ Reduces over-fetching ✔ Better for complex UIs BUT… GraphQL adds complexity fast: - Schema management - Performance tuning - Caching challenges In most SaaS projects I’ve worked on: 👉 REST was more than enough My rule: Use GraphQL ONLY if your frontend really needs flexibility. Otherwise, keep it simple. What do you prefer — REST or GraphQL? #BackendDevelopment #API #GraphQL #RESTAPI #NodeJS #SoftwareArchitecture #TechDiscussion #FullStack #Programming
To view or add a comment, sign in
-
-
The moment a project stopped feeling like a client project. During the project scalability phase the senior team made a call nobody expected. Scrap the current stack. We are rebuilding. LoopBack was holding us back old Node.js framework, limited structure, not built for where this product was going. Management saw it before it became a crisis. The decision came down: migrate to NestJS + TypeScript, introduce CQRS, move to PostgreSQL, containerize with Docker. As a team, we had maybe a week to wrap our heads around it. I remember thinking, this is either going to be a nightmare or the best thing that happened to this project. It was both. The migration was not clean. It never is. But every architectural choice had a clear reason behind it. CQRS because the read/write complexity was growing. Docker because deployment was inconsistent. TypeScript because the team was scaling and we needed guardrails. What changed for me was not the tech. It was watching leadership make a hard call, sacrifice short term velocity for long term stability, and then trusting the team to execute it. That's when I stopped counting hours. I was not just completing tickets anymore. I was building something that was meant to last. That feeling is rare. But once you have felt it, you know exactly what's missing when it's not there. #NodeJS #NestJS #TypeScript #PostgreSQL #Docker #CQRS #BackendDevelopment #SoftwareArchitecture
To view or add a comment, sign in
-
-
Shipping with Docker rewrote my whole deployment experience I just shipped a custom eLibrary platform for NIESV, integrating secure member access control with a full-scale digital repository. Here's what changed my deployment game. Part of the requirement was setting up DSpace, an open-source digital repository platform built with Angular, Java, PostgreSQL, and Solr. I went the manual route first. Version conflicts. Dependency hell. Configuration bugs. You know the drill. Then I found their Docker deployment option. One compose file. Few commands. Done Everything spun up the frontend, backend, database, and search engine. Clean. No drama. That moment shifted something for me. If Docker could simplify a complex multi-service platform like DSpace this much, why wasn't I using it for my own projects? So I containerized my entire stack — Node.js proxy API, Next.js frontend, PostgreSQL. Pushed to GitHub. Pulled on the VPS. For the first time in my deployment story, going live felt smooth. Docker isn't just a DevOps tool. It's a developer superpower. If you're still deploying manually, I recommend trying containerization. 🐳 #Docker #WebDevelopment #NodeJS #NextJS #DSpace #SoftwareEngineering #Deployment #OpenSource
To view or add a comment, sign in
-
-
💻 “It works on my machine.” Every backend developer has said this at least once… and every production server has proved it wrong 😅 🚀 That’s exactly where Docker changes the game. Instead of debugging environment issues for hours, you package everything your app needs into a container. Same code. Same dependencies. Same behavior. 👉 Anywhere. 🔥 Let’s break it down: 🧱 Docker Image = Blueprint Contains your code, runtime, dependencies Immutable → consistent builds every time 📦 Container = Running Instance Lightweight, isolated environment Starts in seconds (unlike VMs) ⚡ Why Backend Developers MUST learn Docker: ✔ No more “works on my machine” bugs ✔ Seamless dev → test → production flow ✔ Perfect for microservices architecture ✔ Easy scaling & deployment ✔ Clean debugging using isolated environments 🧠 Real Dev Insight: Most bugs in production are NOT logic errors… They’re environment mismatches. Docker eliminates that entire category. 🔧 Typical Backend Workflow: Build your API (Spring Boot / Node.js) Create Dockerfile Build Image Run Container Push to Registry Deploy via CI/CD 💡 If you’re a backend developer and NOT using Docker yet… You’re making your life harder than it needs to be. 👉 What was your biggest struggle before learning Docker? #Docker #BackendDevelopment #Java #SpringBoot #DevOps #Microservices #SoftwareEngineering
To view or add a comment, sign in
-
-
Docker is one of those skills that quietly pays off every time you ship something. I liked how this Hostinger guide breaks down using Node.js with Docker in a very practical way: from writing a clean Dockerfile to basic best practices for building, testing, and deploying. Sharing here in case you are tightening up your Node workflow or just starting to containerize your projects: https://lnkd.in/dQ4_QbQe #nodejs #docker #softwaredevelopment
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Great Share Ayush Gupta