-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Labels
Description
Description
Currently, setting up the local development environment requires manually installing specific versions of Node.js and MongoDB, as well as managing separate terminal processes for the client and server. This often leads to "it works on my machine" inconsistencies and increases onboarding time for new contributors.
The goal of this issue is to create a fully containerized environment for the entire MERN stack using Docker Compose. This involves defining Dockerfiles for both the frontend and backend services, setting up a MongoDB container, and configuring network communication between these containers.
Technical Impact
- Onboarding: Reduces setup time from minutes/hours of configuration to a single command.
- Consistency: Eliminates environment-specific bugs caused by varying Node.js or MongoDB versions across different developer machines.
- Isolation: Keeps project dependencies isolated from the host operating system.
Proposed Solution
- Backend Dockerization:
- Create a
server/Dockerfileto build the Node.js/Express backend. - Ensure appropriate ports are exposed.
- Create a
- Frontend Dockerization:
- Create a
client/Dockerfileto build the React frontend.
- Create a
- Docker Compose:
- Create a
docker-compose.ymlfile in the root directory. - Define services for
frontend,backend, anddatabase(MongoDB image). - Configure volumes for data persistence (MongoDB) and hot-reloading (for development).
- Set up internal networking so the backend can communicate with the database container.
- Create a
- Configuration:
- Add a
.dockerignorefile to excludenode_modulesand local logs.
- Add a
Likely Affected Files
docker-compose.yml(new)client/Dockerfile(new)server/Dockerfile(new).dockerignore(new)
Verification Steps
To verify that the Docker setup is working correctly:
- Ensure Docker Desktop or the Docker engine is running on your machine.
- Navigate to the project root and run
docker-compose up --build. - Verify that three containers (frontend, backend, and db) spin up successfully without errors in the terminal logs.
- Open a browser and navigate to
http://localhost:3000(or the configured client port) to ensure the frontend loads. - Perform an action that requires an API call (e.g., logging in or fetching expenses) to verify the frontend can talk to the backend and the backend can talk to the database.
- Stop the containers (
Ctrl+Cordocker-compose down) and restart them to ensure data persistence remains intact.
Labels: ECWoC26
Reactions are currently unavailable