This document provides instructions for running the AI Chatbot application using Docker.
- Docker installed on your system
- Docker Compose (usually included with Docker Desktop)
- Your API keys and environment variables ready
The Docker setup includes:
Dockerfile- Main container configurationdocker-compose.yml- Service orchestration.dockerignore- Files excluded from Docker build
Create a .env file in the project root with your configuration:
# Server Configuration
PORT=3000
NODE_ENV=production
# Authentication
AUTH_SEED=your-secret-jwt-seed-here
# OpenAI Configuration
OPENAI_API_KEY=your-openia-api-key-here
# Pinecone Configuration
PINECONE_API_KEY=your-pinecone-api-key-here
PINECONE_ENVIRONMENT=your-pinecone-environment
PINECONE_INDEX_NAME=your-pinecone-index-name# Build and start the application
docker-compose up --build
# Or run in detached mode
docker-compose up -d --buildThe application will be available at http://localhost:3000
# Build the Docker image
docker build -t ai-chatbot .
# Run the container
docker run -p 3000:3000 --env-file .env ai-chatbot# Run development service with hot reload
docker-compose --profile dev up ai-chatbot-dev# View running containers
docker-compose ps
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild containers
docker-compose up --buildThe container includes health checks that verify the application is responding properly:
- Interval: 30 seconds
- Timeout: 3 seconds
- Retries: 3 attempts
- Start Period: 5 seconds
Check container health:
docker-compose ps- Uses Node.js Alpine image for smaller attack surface
- Runs as non-root user (
nextjs) - Excludes sensitive files via
.dockerignore - Environment variables for configuration
- Base Image:
node:18-alpine - Package Manager: pnpm (for faster installs)
- Port: 3000
- User: nextjs (non-root)
- Working Directory:
/app
# Check logs
docker-compose logs ai-chatbot
# Check if port is already in use
netstat -an | findstr :3000 # Windows
lsof -i :3000 # macOS/Linux- Ensure
.envfile exists in project root - Check file permissions
- Verify variable names match exactly
# Clean build (remove cache)
docker-compose build --no-cache
# Check Docker disk space
docker system df# Reset file permissions (Unix-based systems)
sudo chown -R $USER:$USER .For production deployment:
- Environment Variables: Set secure values for all API keys
- Reverse Proxy: Use nginx or similar for SSL termination
- Resource Limits: Add memory and CPU limits to docker-compose.yml
- Monitoring: Implement logging and monitoring solutions
- Backup: Ensure data persistence strategies
# docker-compose.prod.yml
version: '3.8'
services:
ai-chatbot:
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
restart: alwaysRun with: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
- The application uses ES modules (
"type": "module") - pnpm is used for faster package installation
- Development mode mounts source code for hot reload
- Health checks ensure container reliability
- All test files and documentation are excluded from the build
server.js- Application entry pointpackage.json- Dependencies and scriptsjest.config.js- Test configurationtests/README.md- Testing documentation