This guide explains how to containerize and deploy the Civic Issues project using Docker so all team members can run it easily.
Before starting, ensure your team has:
- Docker Desktop installed (download here)
- Git installed
- Clone the repository:
git clone <repository-url>
Docker Compose automatically sets up both the application and MongoDB database.
-
Copy the example file:
cp .env.example .env.local
-
Edit
.env.localand update the values as needed:MONGODB_URI=mongodb://mongo:27017 JWT_SECRET=your_secret_key_here # ... other environment variables
Run the application with a single command:
docker-compose up --buildThis will:
- Build the Docker image
- Start the application on
http://localhost:3000 - Start MongoDB on
localhost:27017
To run in background:
docker-compose up -d --builddocker-compose psYou should see two containers running:
civic-issues-appcivic-issues-mongo
docker-compose downTo also remove volumes (database data):
docker-compose down -vIf you want team members to pull a pre-built image instead of building locally:
- Sign up at hub.docker.com
docker build -t yourusername/civic-issues:latest .docker logindocker push yourusername/civic-issues:latestTeam members can now pull and run it with:
docker run -d \
-p 3000:3000 \
-e MONGODB_URI=mongodb://mongo:27017 \
--name civic-app \
yourusername/civic-issues:latestIf not using docker-compose:
docker build -t civic-issues .docker run -d \
--name civic-mongo \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=password123 \
mongo:7.0-alpinedocker run -d \
--name civic-app \
-p 3000:3000 \
-e MONGODB_URI=mongodb://civic-mongo:27017 \
--link civic-mongo:mongo \
civic-issuesAccess the app at http://localhost:3000
| Command | Purpose |
|---|---|
docker-compose logs |
View application logs |
docker-compose logs -f |
Follow logs in real-time |
docker-compose exec app npm run lint |
Run commands inside container |
docker ps |
List running containers |
docker images |
List available images |
docker rm <container-id> |
Remove a container |
docker rmi <image-id> |
Remove an image |
-
Push to GitHub (you likely already do this)
-
Team members clone:
git clone <repository-url> cd sih
-
Team members run with Docker Compose:
cp .env.example .env.local docker-compose up
-
Access at:
http://localhost:3000
If port 3000 is already in use, change it in docker-compose.yml:
ports:
- "8080:3000" # Access on http://localhost:8080Ensure MongoDB is running:
docker-compose psIf MongoDB isn't running:
docker-compose up mongoOn Linux/Mac, you may need to:
sudo usermod -aG docker $USERThen log out and log back in.
To start fresh:
docker-compose down -v
docker system prune -aUpdate these in .env.local based on your needs:
MONGODB_URI: MongoDB connection stringNODE_ENV: Set to 'production' in DockerNEXT_PUBLIC_API_URL: Your application's public URLJWT_SECRET: Secret key for authentication tokens- Other API keys as needed (Cloudinary, Mailgun, etc.)
- ✅ Create a
.env.localfile from.env.example - ✅ Run
docker-compose up - ✅ Share the Docker Hub link with team members (if pushing to registry)
- ✅ Update your GitHub README with Docker setup instructions
Happy deploying! 🚀