Skip to content

Conversation

@rishabh0510rishabh
Copy link
Contributor

Dockerize MERN Stack Environment

Description

This PR introduces a fully containerized development environment using Docker Compose, replacing the manual setup of Node.js and MongoDB. It separates the frontend and backend into distinct services to simulate a production-like architecture (Nginx for static files, Node.js for API).

Changes

  • Backend: Created server/Dockerfile to containerize the Node.js/Express application.
  • Frontend: Created client/Dockerfile and client/nginx.conf to serve static assets via Nginx.
    • Feature Parity: Added security headers (CSP, X-Frame-Options) to Nginx to match existing Helmet configuration.
  • Orchestration: Added docker-compose.yml to streamline the startup of Frontend, Backend, and MongoDB.
  • Config: Added .dockerignore and a default .env (derived from .env.example).

Verification

The following verification steps were performed via static analysis (due to local Docker environment constraints):

  1. Frontend Routing: Verified nginx.conf handles static files and proxies /api and /socket.io requests to the backend.
  2. Security: Replicated key security headers from server.js (Helmet) into nginx.conf to ensure no security regression.
  3. File Integrity: Scanned frontend code for external file references; confirmed all assets are within public/.

How to Run

  1. Ensure Docker Desktop is running.
  2. Run: docker-compose up --build
  3. Access:
    • Frontend: http://localhost:3000
    • API: http://localhost:3000/api
    • Database: mongodb://localhost:27017

Checklist

  • Dockerfiles created
  • Docker Compose configured
  • Networking (Frontend -> Backend -> DB) setup
  • Security headers preserved

Label: ECWoC26

Related issue: #577

Introduce containerization: add .dockerignore, client and server Dockerfiles, and an Nginx config for the frontend. Replace the previous single-service compose with a docker-compose defining frontend (Nginx), backend (Node.js) and mongo services, add a mongo data volume, environment variables and env_file for the backend, and set restart policies. Port mappings: frontend 3000:80, backend 3001:3000. Nginx proxies /api and /socket.io to the backend and applies basic security headers/CSP. Also adjust compose version to 3.8 to support the layout.
@github-actions
Copy link

🎉 Thanks for the PR, @rishabh0510rishabh!

We really appreciate you taking the time to contribute to ExpenseFlow! 💙


⭐ Love this project?

Please give us a star! It helps the project grow and reach more developers! 🌟

🔗 https://github.com/Renu-code123/ExpenseFlow


✅ PR Checklist

Before we review, please ensure:

  • Your code follows the project's coding standards
  • All file changes are accurate and intentional
  • You've tested your changes locally
  • Any review comments have been addressed

🙌 Thank You for Contributing!

We truly appreciate your interest in contributing to this project.

  • Please make sure your code follows the project structure
  • Add clear commit messages and comments where necessary
  • Ensure your changes do not break existing functionality

We'll review your PR as soon as possible. Keep up the great work! ✨


@vercel
Copy link

vercel bot commented Feb 10, 2026

@rishabh0510rishabh is attempting to deploy a commit to the Renu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
expenseflow Ready Ready Preview, Comment Feb 11, 2026 0:41am

@Renu-code123 Renu-code123 merged commit 25ebcfc into Renu-code123:main Feb 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants