This contains databases infrastructure for the Jasper Bot using Docker containers. It sets up MongoDB and Redis services in an isolated Docker network with fixed IP addresses.
The Jasper Databases [MongoDB and Redis] contains:
- MongoDB: Database service for persistent data storage
- Redis: In-memory cache and session storage
- Docker Network: Isolated network configuration for service communication
- Docker Engine
- Docker Compose
-
Configure Environment Variables
Copy the example environment files and customize them for your setup:
# Copy example files to active configuration cp env/example.mongo.env env/mongo.env cp env/example.redis.env env/redis.env⚠️ Important: Edit the environment files to match your security requirements:For MongoDB (
env/mongo.env):MONGO_INITDB_ROOT_USERNAME=jasper # Change this username MONGO_INITDB_ROOT_PASSWORD=jasper123 # Change this password MONGO_INITDB_DATABASE=jasperdb # Change database name if needed
For Redis (
env/redis.env):REDIS_PASSWORD=jasper123 # Change this password REDIS_PORT=6379 # Keep as 6379 unless you have conflicts
-
Create the Docker Network
chmod +x docker_network.sh ./docker_network.sh
-
Start the Services
docker-compose up -d
-
Verify Services are Running
docker-compose ps
The project uses environment files to configure the services. You must customize these before deployment:
# MongoDB Configuration
MONGODB=mongodb://jasper:jasper123@172.30.1.3:27017/jasperdb?authSource=admin
# Redis Configuration
REDISHOST=172.30.1.2
REDISPORT=6379MongoDB Environment (env/mongo.env):
MONGO_INITDB_ROOT_USERNAME=jasper # ← Change this username
MONGO_INITDB_ROOT_PASSWORD=jasper123 # ← Change this password
MONGO_INITDB_DATABASE=jasperdb # ← Change database name if neededRedis Environment (env/redis.env):
REDIS_PASSWORD=jasper123 # ← Change this password
REDIS_PORT=6379 # ← Keep as 6379 unless you have conflictsAfter changing the credentials, update your bot's .env file accordingly:
# If you changed MongoDB credentials, update the connection string:
MONGODB=mongodb://YOUR_USERNAME:YOUR_PASSWORD@172.30.1.3:27017/YOUR_DATABASE?authSource=admin
# Redis configuration (update if you changed the password):
REDISHOST=172.30.1.2
REDISPORT=6379- Network Name:
jasper_network - Subnet:
172.30.1.0/24 - MongoDB IP:
172.30.1.3 - Redis IP:
172.30.1.2
apps/databases
├── docker-compose.yml # Main Docker Compose configuration
├── docker_network.sh # Network creation script
├── README.md # This documentation
├── env/ # Environment files
│ ├── mongo.env # MongoDB environment variables
│ ├── redis.env # Redis environment variables
│ ├── example.mongo.env # MongoDB example configuration
│ └── example.redis.env # Redis example configuration
└── volumes/ # Persistent data storage
├── mongodb_data/ # MongoDB data directory
└── redis_data/ # Redis data directory
- Container Name:
jasper_mongo - Image:
mongo:8-noble - Internal IP:
172.30.1.3 - Port:
27017(internal only) - Database:
jasperdb(or your custom database name) - Username:
jasper(or your custom username) - Password:
jasper123(or your custom password)
Connection String: mongodb://[username]:[password]@172.30.1.3:27017/[database]?authSource=admin
- Container Name:
jasper_redis - Image:
redis:latest - Internal IP:
172.30.1.2 - Port:
6379(internal only) - Password:
jasper123(or your custom password)
docker-compose up -ddocker-compose down# All services
docker-compose logs -f
# Specific service
docker-compose logs -f jasper_mongo
docker-compose logs -f jasper_redisdocker-compose restartdocker-compose psIf you encounter network connection issues:
-
Verify the network exists:
docker network ls | grep jasper_network -
Recreate the network if needed:
docker network rm jasper_network ./docker_network.sh
-
Check if services are running:
docker-compose ps
-
Test MongoDB connection (adjust credentials if you changed them):
docker exec -it jasper_mongo mongosh mongodb://jasper:jasper123@localhost:27017/jasperdb?authSource=admin
-
Test Redis connection (adjust password if you changed it):
docker exec -it jasper_redis redis-cli -a jasper123
- MongoDB data is persisted in
./volumes/mongodb_data/ - Redis data is persisted in
./volumes/redis_data/ - These directories are automatically created when containers start
- Services are only accessible within the Docker network
- Ports are not exposed to the host system for security
⚠️ Default credentials are provided in example files - CHANGE THEM for any real deployment- Consider using Docker secrets or external secret management for production environments
- The example passwords (
jasper123) should never be used in production
This infrastructure is designed to work seamlessly with the Jasper Bot application. After customizing your environment files, update the bot's .env file with the corresponding values:
# Update these values to match your env/mongo.env and env/redis.env files
MONGODB=mongodb://[YOUR_USERNAME]:[YOUR_PASSWORD]@172.30.1.3:27017/[YOUR_DATABASE]?authSource=admin
REDISHOST=172.30.1.2
REDISPORT=6379Example with default values (change these for production):
MONGODB=mongodb://jasper:jasper123@172.30.1.3:27017/jasperdb?authSource=admin
REDISHOST=172.30.1.2
REDISPORT=6379- The
docker-compose.ymlhas commented port mappings for security - Uncomment port mappings if you need external access during development
- The network uses a custom subnet to avoid conflicts with other Docker networks