This guide provides detailed instructions for setting up and using PrivacyChatBoX with Docker, making deployment easy and consistent across environments.
Before starting, ensure you have:
- Docker installed (version 20.10.0 or higher)
- Docker Compose installed (version 2.0.0 or higher)
- Git (optional, for cloning the repository)
Clone the repository or download the source code:
git clone https://github.com/yourusername/PrivacyChatBoX.git
cd PrivacyChatBoXYou have two options to configure environment variables:
Create a .env file in the project root directory with your API keys:
# Database Configuration (already set in docker-compose.yml)
# DATABASE_URL=postgresql://postgres:postgres@db:5432/privacychatbox
# AI Provider API Keys
OPENAI_API_KEY=your_openai_api_key
CLAUDE_API_KEY=your_claude_api_key
GEMINI_API_KEY=your_gemini_api_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=http://localhost:5000/
# Microsoft DLP Integration (if needed)
MS_TENANT_ID=your_tenant_id
MS_CLIENT_ID=your_client_id
MS_CLIENT_SECRET=your_client_secret
Alternatively, you can directly edit the docker-compose.yml file and uncomment the environment variables section.
For production use:
docker-compose up -dThis command:
- Builds the application container if it doesn't exist
- Creates and starts the PostgreSQL database container
- Creates and starts the application container
- Sets up persistent volumes for data and models
- Runs in detached mode (-d)
Open your web browser and navigate to:
http://localhost:5000
Use the default login credentials:
- Username: admin (or
DEFAULT_ADMIN_USERNAME) - Password: a random temporary password printed in the server log on first start (
docker-compose logs appfor Docker), orDEFAULT_ADMIN_PASSWORDif you set a strong one. You must change it at first login.
Important: Change the admin password after your first login through the Admin panel.
For development purposes, use:
docker-compose -f docker-compose.yml -f docker-compose.override.yml upThis gives you:
- Live code reloading (your local files are mounted into the container)
- Adminer database management tool at http://localhost:8080
- Containers running in foreground with visible logs
- Open http://localhost:8080 in your browser
- Log in with:
- System: PostgreSQL
- Server: db
- Username: postgres
- Password: postgres
- Database: privacychatbox
docker-compose psdocker-compose downTo also remove volumes (WARNING: this deletes all data):
docker-compose down -v# All logs
docker-compose logs
# Application logs only
docker-compose logs app
# Database logs only
docker-compose logs db
# Follow logs in real-time
docker-compose logs -fIf you've made changes to the Dockerfile:
docker-compose build
docker-compose up -dPrivacyChatBoX uses two main containers:
-
app: The main application container
- Based on Python 3.11
- Runs Streamlit on port 5000
- Contains all application code
- Handles database migrations on startup
-
db: PostgreSQL database
- Uses PostgreSQL 15 Alpine image
- Stores all application data
- Accessible to the app container
Two persistent volumes are configured:
-
postgres_data: Stores the database data
- Location: /var/lib/postgresql/data in the db container
- Persists between container restarts
-
models_data: Stores downloaded local LLM models
- Location: /app/models in the app container
- Persists between container restarts
Both containers run on the same Docker network, allowing:
- The app container to access the db container via hostname "db"
- Port 5000 to be exposed to the host machine
- Port 8080 (Adminer) to be exposed in development mode
Check the logs:
docker-compose logs appCommon issues:
- Database connection problems
- Missing environment variables
- Permission issues with mounted volumes
Verify database container is running:
docker-compose ps dbCheck database logs:
docker-compose logs dbEnsure environment variables match in docker-compose.yml:
DATABASE_URL=postgresql://postgres:postgres@db:5432/privacychatbox
You can access a shell in the running container:
docker-compose exec app bashFrom here, you can:
- Run Python scripts directly
- Check file permissions
- Verify environment variables
- Run database migrations manually
If migrations fail, you can run them 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.pyFor production deployment:
- Don't expose Adminer: Remove docker-compose.override.yml in production
- Use Secrets Management:
- Consider using Docker Secrets or environment variables instead of hardcoding in docker-compose.yml
- Never commit .env files with sensitive information to version control
- Set Strong Passwords:
- Change default PostgreSQL password
- Change admin user password immediately
-
Allocate Sufficient Resources:
- CPU/Memory limits can be set in docker-compose.yml
- Consider your workload when sizing containers
-
Database Tuning:
- PostgreSQL can be tuned for performance by setting environment variables in docker-compose.yml
For regular database backups:
# Backup
docker-compose exec db pg_dump -U postgres privacychatbox > backup_$(date +%Y%m%d).sql
# Restore
cat backup_file.sql | docker-compose exec -T db psql -U postgres privacychatboxTo use a different port (e.g., 8888 instead of 5000), edit docker-compose.yml:
ports:
- "8888:5000" # Maps host port 8888 to container port 5000To use an external PostgreSQL server instead of the container:
- Edit docker-compose.yml to remove the db service
- Update the DATABASE_URL environment variable to point to your external PostgreSQL server
- Remove the depends_on section for the db service
For production deployments, consider adding a reverse proxy (like Nginx or Traefik) with SSL termination.