1.6 KiB
1.6 KiB
Docker Setup for Recipe Management App
MongoDB Configuration
This project now includes a Docker Compose setup for MongoDB with persistent storage.
Environment Variables
Create a .env file in the backend/ directory with the following variables:
# MongoDB Configuration (parameterized for security)
MONGODB_USERNAME=admin
MONGODB_PASSWORD=password123
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_DATABASE=recipe-management
# Alternative: Use full connection string (overrides individual parameters)
# MONGODB_URI=mongodb://admin:password123@localhost:27017/recipe-management?authSource=admin
# Server Configuration
PORT=5000
Note: The application will automatically construct the MongoDB URI from the individual parameters. You can also override this by setting MONGODB_URI directly.
Starting the Services
- Start MongoDB and Mongo Express:
docker-compose up -d
- Start the backend application:
cd backend
npm start
Services Included
- MongoDB: Database server on port 27017 with persistent volume
- Mongo Express: Web-based MongoDB admin interface on port 8081
Default Credentials
- MongoDB Admin User: admin
- MongoDB Admin Password: password123
- Database Name: recipe-management
Accessing Services
- Mongo Express: http://localhost:8081
- Backend API: http://localhost:5000
Data Persistence
MongoDB data is stored in a Docker volume named mongodb_data which persists between container restarts.
Seed Data
The seed data from backend/seedData.js is automatically loaded when the MongoDB container starts for the first time.