This guide will help you containerize and deploy the Lumi Chatbot using Docker and Docker Compose.
Copy the example environment file:
cp .env.docker.example .env
Edit .env and add your API keys:
OPENAI_API_KEY=sk-your-actual-key
PINECONE_API_KEY=pc-your-actual-key
PINECONE_INDEX_NAME=your-index-name
PINECONE_ENVIRONMENT=us-east-1-aws
Generate application key:
cd lumi-backend
cp .env.example .env # if it doesn't exist
php artisan key:generate
Copy the generated APP_KEY value to your .env file in the root.
From the project root:
# Build images
docker-compose build
# Start services
docker-compose up -d
# Check logs
docker-compose logs -f
Run migrations:
docker-compose exec laravel php artisan migrate --force
┌──────────────┐
│ Nginx │ Port 80/443 (Reverse Proxy)
│ (optional) │
└──────┬───────┘
│
├─────────────► Laravel (Port 8000)
│ - API endpoints
│ - Filament admin
│
└─────────────► Streamlit (Port 8501)
- Chatbot interface
lumi-laravellumi-chatbotlumi-nginxdocker-compose up -d
docker-compose down
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f laravel
docker-compose logs -f chatbot
# Rebuild specific service
docker-compose build laravel
docker-compose up -d laravel
# Rebuild all
docker-compose build
docker-compose up -d
# Laravel artisan
docker-compose exec laravel php artisan migrate
# Install new PHP dependency
docker-compose exec laravel composer require package/name
# Python shell
docker-compose exec chatbot python manage_documents.py --help
# Laravel container
docker-compose exec laravel bash
# Chatbot container
docker-compose exec chatbot bash
The docker-compose.yml uses volumes for development:
./lumi-backend:/var/www/html - Laravel code sync./lumi-backend/chatbot:/app - Chatbot code syncChanges to your local files will immediately reflect in the containers.
If you don't need Nginx, comment it out in docker-compose.yml:
# services:
# nginx:
# ...
Access services directly: - Laravel: http://your-domain:8000 - Chatbot: http://your-domain:8501
Update nginx.conf:
nginx
server_name your-actual-domain.com;
Add SSL Certificates:
bash
# Place your SSL cert and key:
nginx/ssl/cert.pem
nginx/ssl/key.pem
Uncomment HTTPS block in nginx.conf
Update embed script URL:
Edit chatbot-embed.js to use your domain:
javascript
chatUrl: 'https://your-domain.com',
Update .env:
APP_ENV=production
APP_DEBUG=false
Database and uploads are preserved in named volumes:
# Backup database
docker-compose exec laravel sqlite3 database/database.sqlite .dump > backup.sql
# Restore database
cat backup.sql | docker-compose exec -T laravel sqlite3 database/database.sqlite
Check network connectivity:
docker-compose exec chatbot ping laravel
docker-compose exec chatbot curl http://laravel:8000/api/health
Verify LARAVEL_API_BASE_URL in chatbot environment:
docker-compose exec chatbot env | grep LARAVEL
Fix storage permissions:
docker-compose exec laravel chown -R www-data:www-data storage bootstrap/cache
docker-compose exec laravel chmod -R 775 storage bootstrap/cache
SQLite can have issues with concurrent access. Options:
Use MySQL/PostgreSQL: Add MySQL service to docker-compose.yml
Enable WAL mode: ```bash docker-compose exec laravel php artisan tinker
DB::statement('PRAGMA journal_mode=WAL;'); ```
Change ports in docker-compose.yml:
ports:
- "8080:8000" # Instead of 8000:8000
docker stats
To run multiple chatbot instances:
chatbot:
# ... existing config ...
deploy:
replicas: 3
Then use Nginx for load balancing:
upstream streamlit_chatbot {
server chatbot:8501;
server chatbot:8502;
server chatbot:8503;
}
Both services have health checks configured.
Check status:
docker-compose ps
Healthy services show (healthy) status.
View real-time logs:
# All services
docker-compose logs -f
# Last 100 lines
docker-compose logs --tail=100
# Specific service
docker-compose logs -f chatbot
docker-compose down -v
docker-compose down --rmi all
docker-compose down -v --rmi all
docker system prune -a
If you prefer not to use docker-compose:
cd lumi-backend
docker build -t lumi-laravel .
docker run -d -p 8000:8000 --name laravel lumi-laravel
cd lumi-backend/chatbot
docker build -t lumi-chatbot .
docker run -d -p 8501:8501 \
-e OPENAI_API_KEY=sk-... \
-e PINECONE_API_KEY=pc-... \
--name chatbot lumi-chatbot
For issues:
1. Check logs: docker-compose logs
2. Verify environment variables
3. Check network connectivity between services
4. Review health check status
Note: This Docker setup is production-ready but should be tested in a staging environment first before deploying to production.