-
Create environment file (if not exists):
cp .env.example .env
Edit
.envand add your MongoDB connection string. -
Build and run containers:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:4000
docker-compose builddocker-compose updocker-compose up -ddocker-compose downdocker-compose logs -fdocker-compose logs -f backend
docker-compose logs -f frontenddocker-compose up --builddocker-compose down -v- Backend: Node.js/Express server running on port 4000
- Frontend: React app built with Vite, served via Nginx on port 80 (mapped to 5173)
- Network: Both services communicate via
hms-networkbridge network - Nginx Proxy: Frontend nginx proxies
/apiand/socket.iorequests to backend
MONGO_URI: MongoDB connection stringPORT: Backend server port (default: 4000)NODE_ENV: Environment (production/development)
- Uses relative URLs in production (via nginx proxy)
- Uses
localhost:4000in development mode
If port 4000 or 5173 is already in use, modify the ports in docker-compose.yml:
ports:
- "4001:4000" # Change 4000 to 4001- Verify your
MONGO_URIin.envfile - Check MongoDB Atlas IP whitelist (add 0.0.0.0/0 for Docker)
- Ensure MongoDB credentials are correct
- Check that both containers are running:
docker-compose ps - Verify nginx proxy configuration in
frontend/nginx.conf - Check browser console for CORS or connection errors
docker-compose up --buildFor production, consider:
- Using environment-specific
.envfiles - Setting up SSL/TLS certificates
- Using a reverse proxy (Traefik, Nginx)
- Setting resource limits in docker-compose.yml
- Using Docker secrets for sensitive data