This guide provides detailed instructions for deploying PrivacyChatBoX using Docker and Docker Compose, including troubleshooting tips and best practices.
Before you begin, ensure you have the following installed on your system:
- Docker Engine (version 20.10.0 or higher)
- Docker Compose (version 2.0.0 or higher)
- Git (optional, for cloning the repository)
Either clone the repository or download and extract the source code:
git clone https://github.com/yourusername/PrivacyChatBoX.git
cd PrivacyChatBoXYou can configure environment variables in two ways:
- Create a
.envfile in the project root directory with your API keys and settings:
# AI Provider Keys
OPENAI_API_KEY=your_openai_key
CLAUDE_API_KEY=your_claude_key
GEMINI_API_KEY=your_gemini_key
SERPAPI_KEY=your_serpapi_key
# Azure AD Integration (if needed)
AZURE_TENANT_ID=your_azure_tenant_id
AZURE_CLIENT_ID=your_azure_client_id
AZURE_CLIENT_SECRET=your_azure_client_secret
AZURE_REDIRECT_URI=your_redirect_uri
# Microsoft DLP Integration (if needed)
MS_TENANT_ID=your_tenant_id
MS_CLIENT_ID=your_client_id
MS_CLIENT_SECRET=your_client_secret
- Or, edit the
docker-compose.ymlfile directly to add your environment variables.
Run the following command to start the application in detached mode:
docker-compose up -dThis will:
- Build the Docker image (if not already built)
- Create and start the PostgreSQL database container
- Create and start the application container
- Create persistent volumes for the database and local LLM models
Open your web browser and navigate to:
http://localhost:5000
To stop the application, run:
docker-compose downTo stop the application and remove all volumes (WARNING: this will delete all data, including the database):
docker-compose down -vFor development purposes, an extended configuration is provided in docker-compose.override.yml:
# Start with development configuration
docker-compose -f docker-compose.yml -f docker-compose.override.yml upThis configuration includes:
- Mounting the current directory into the container for live code changes
- Adding Adminer for database management (accessible at http://localhost:8080)
- Setting a DEVELOPMENT environment variable
Problem: The application can't connect to the database.
Solutions:
-
Check if the database container is running:
docker-compose ps
-
Check database logs:
docker-compose logs db
-
Ensure the database environment variables in
docker-compose.ymlmatch the connection string:DATABASE_URL=postgresql://postgres:postgres@db:5432/privacychatbox
Problem: The application container exits immediately or fails to start.
Solutions:
-
Check application logs:
docker-compose logs app
-
Run the container in interactive mode to debug:
docker-compose run --rm app bash
-
Check if the entrypoint script is executable:
docker-compose exec app ls -la /app/docker-entrypoint.sh
Problem: Database migrations are failing.
Solutions:
-
Check migration logs:
docker-compose logs app
-
Run migrations manually:
docker-compose exec app python database_check.py docker-compose exec app python migration_add_dlp_columns.py docker-compose exec app python migration_add_local_llm_columns.py docker-compose exec app python migration_pattern_levels.py
Problem: The port 5000 is already in use on your system.
Solution:
- Modify the port mapping in
docker-compose.yml:ports: - "8888:5000" # Change 5000 to an available port on your host
To use a different PostgreSQL version, modify the db service in docker-compose.yml:
db:
image: postgres:14-alpine # Change to your preferred versionTo reduce the Docker image size:
- Use multi-stage builds in your Dockerfile
- Remove development dependencies
- Use Alpine-based images where possible
For production deployments, consider:
-
Use Secrets Management:
- Don't store API keys in the Docker Compose file
- Use Docker secrets or a secure environment variable management solution
-
Configure HTTPS:
- Set up a reverse proxy (Nginx, Traefik) with SSL termination
- Obtain and configure SSL certificates
-
Database Backup Strategy:
- Set up regular PostgreSQL backups
- Consider using a managed database service instead of a container
-
Monitoring:
- Add health checks to the docker-compose.yml
- Set up container monitoring and logging