Skip to content

Feat(Docker): Add Production-Ready Multi-Stage Docker Setup#7

Open
AnubhavGitHub07 wants to merge 1 commit intodevelopfrom
task-dockerization
Open

Feat(Docker): Add Production-Ready Multi-Stage Docker Setup#7
AnubhavGitHub07 wants to merge 1 commit intodevelopfrom
task-dockerization

Conversation

@AnubhavGitHub07
Copy link
Copy Markdown
Owner

@AnubhavGitHub07 AnubhavGitHub07 commented Mar 9, 2026

Description

Production-ready multi-stage Docker setup for Codelabz with separate development and production environments.


Changes

File Purpose
Dockerfile 3-stage multi-stage build (deps → builder → nginx:alpine) — 102MB final image
Dockerfile.dev Dev environment with Node 18 + JRE for Firebase Emulators
docker-compose.yml Production compose with build args, health check, restart policy
docker-compose.dev.yml Dev compose with hot-reload volumes & emulator ports
nginx.conf SPA routing, gzip compression, security headers, asset caching
.dockerignore ~60 exclusion patterns for build context optimization
scripts/entrypoint.sh Dev container startup (emulators + Vite)
DOCKER.md Setup instructions, commands, troubleshooting guide

Motivation and Context

The existing Docker setup had critical issues:

  1. Node 14 (EOL) — no security updates
  2. ~1.2GB image — single-stage build with all dev dependencies
  3. Vite dev server in production — not production-ready
  4. No documentation — no setup instructions for contributors

This PR replaces it with a multi-stage build using Nginx for production serving, upgrades runtime to Node 18, and provides separate dev/prod environments with comprehensive documentation.


How Has This Been Tested?

Production Build

docker build -t codelabz:production .

✅ Exit code: 0
✅ Image size: 102MB
✅ Build time: ~130s


Production Run

docker run -d -p 8080:80 --name codelabz-test codelabz:production

✅ HTTP 200 at http://localhost:8080


Health Check

docker inspect --format='{{.State.Health.Status}}' codelabz-test

Result:

healthy

Security Headers Verification

curl -sI http://localhost:8080/

Verified headers:

  • X-Frame-Options
  • X-Content-Type-Options
  • X-XSS-Protection
  • Referrer-Policy

No Source Code in Production Image

docker run --rm codelabz:production ls /usr/share/nginx/html/

✅ Only static assets present
❌ No node_modules
❌ No src
❌ No .env


Development Compose

docker compose -f docker-compose.dev.yml up --build

✅ Vite dev server running at :5173
✅ Firebase Emulators running


Testing Environment

  • macOS
  • Docker Desktop
  • Docker Compose v2

Testing Screenshots

  1. Production Image Build (Multi-Stage)
Screenshot 2026-03-10 at 2 50 30 AM
  1. Image Size — 102MB
Screenshot 2026-03-10 at 2 42 37 AM
  1. Container Running — Health Check Verified
Screenshot 2026-03-10 at 2 45 16 AM
  1. No Source Code in Production Image
Screenshot 2026-03-10 at 2 45 41 AM
  1. Security Headers Present
Screenshot 2026-03-10 at 2 46 03 AM
  1. Application Served via Nginx ( Port : 8080 )
Screenshot 2026-03-10 at 2 50 09 AM

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@github-actions github-actions Bot added bug Something isn't working dependency documentation Improvements or additions to documentation feature firebase UI/UX labels Mar 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Visit the preview URL for this PR (updated for commit d694718):

https://codelabz-anubhav--pr-7-bh8ukm81.web.app

(expires Mon, 16 Mar 2026 21:27:39 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: daeac1a46194ebcbfcb5f24f714b8354e16dd037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependency documentation Improvements or additions to documentation feature firebase UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant