<!-- source: https://deepwiki.com/MervinPraison/PraisonAI/9-deployment-and-infrastructure -->

# Deployment and Infrastructure

- .gitignore
- docker/Dockerfile
- docker/Dockerfile.chat
- docker/Dockerfile.dev
- docker/Dockerfile.ui
- docker/README.md
- src/praisonai-agents/pyproject.toml
- src/praisonai-agents/uv.lock
- src/praisonai/praisonai.rb
- src/praisonai/praisonai/cli/main.py
- src/praisonai/praisonai/deploy.py
- src/praisonai/praisonai/version.py
- src/praisonai/pyproject.toml
- src/praisonai/uv.lock

This document covers the deployment options, infrastructure setup, and environment configuration for PraisonAI. It includes Docker containerization, cloud deployment to Google Cloud Platform, development environment setup, and configuration management strategies.

For information about CI/CD pipelines and automated testing, see [Testing and Quality Assurance](/MervinPraison/PraisonAI/11-testing-and-quality-assurance). For package structure and dependency management details, see [Package System](/MervinPraison/PraisonAI/10-package-system).

## Overview

PraisonAI provides multiple deployment strategies:

- Docker Containers : Containerized services for UI, Chat, API, and development environments
- Cloud Deployment : Automated deployment to Google Cloud Run via CloudDeployer class
- Local Development : Virtual environment setup with UV package manager for fast dependency installation
- Configuration Management : Unified configuration directory ( ~/.praison ) to avoid cluttering root filesystem

All deployment targets share a common configuration approach using environment variables and the `.env` file pattern, enabling consistent behavior across environments.

## Docker Service Architecture

```

```

**Title**: Docker Service Architecture and Configuration Flow

The Docker setup provides four specialized images, each with specific purposes:

**Sources**: [docker/Dockerfile.ui1-47](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.ui#L1-L47) [docker/Dockerfile.chat1-33](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.chat#L1-L33) [docker/Dockerfile1-47](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile#L1-L47) [docker/Dockerfile.dev1-47](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.dev#L1-L47) [docker/README.md1-264](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L1-L264)

### Configuration Directory Structure

All Docker services use a unified configuration directory to avoid cluttering the root filesystem. The directory structure is:

```
~/.praison/
|-- database.sqlite           # Chainlit conversation database
|-- chainlit.md              # Chainlit configuration file
|-- .chainlit/               # Chainlit runtime files
|   |-- config.toml
|   `-- .files/             # Uploaded file storage
`-- config/                  # PraisonAI configuration files
```

This is configured via three environment variables set in all Dockerfiles:

```
PRAISON_CONFIG_DIR=/root/.praison
CHAINLIT_CONFIG_DIR=/root/.praison
CHAINLIT_DB_DIR=/root/.praison
```

**Sources**: [docker/Dockerfile.ui26-29](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.ui#L26-L29) [docker/Dockerfile.chat26-29](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.chat#L26-L29) [docker/Dockerfile28-30](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile#L28-L30) [docker/README.md54-67](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L54-L67)

### Single Service Deployment

Each Docker image can be run independently:

```

```

The volume mount (`-v ~/.praison:/root/.praison`) ensures persistent storage of configuration and database files across container restarts.

**Sources**: [docker/README.md23-33](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L23-L33)

### Multi-Service Orchestration

```

```

**Title**: Docker Compose Multi-Service Architecture

Docker Compose manages multiple services with shared configuration and networking:

```

```

Each service includes a health check that monitors availability:

```

```

**Sources**: [docker/README.md35-51](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L35-L51) [docker/README.md113-119](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L113-L119) [docker/README.md153-165](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L153-L165)

## Cloud Deployment

```

```

**Title**: CloudDeployer Deployment Pipeline to GCP Cloud Run

The `CloudDeployer` class automates deployment to Google Cloud Platform's Cloud Run service.

### CloudDeployer Workflow

```

```

**Title**: CloudDeployer Execution Sequence

The deployment process creates two files dynamically:

1. Dockerfile - Defines the container image:

```

```

1. api.py - Flask application with PraisonAI integration:

```

```

**Sources**: [src/praisonai/praisonai/deploy.py1-186](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/deploy.py#L1-L186) [docker/Dockerfile1-47](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile#L1-L47)

### Environment Variable Configuration

The `CloudDeployer` uses three primary environment variables, loaded from `.env` or system environment:

These are set in two locations:

1. Initialization deploy.py 93-96 :
2. Cloud Run deployment deploy.py 131-149 - Passed as --set-env-vars to gcloud run deploy

**Sources**: [src/praisonai/praisonai/deploy.py92-96](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/deploy.py#L92-L96) [src/praisonai/praisonai/deploy.py131-149](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/deploy.py#L131-L149)

### Platform-Specific Handling

The deployment handles Windows and Unix platforms differently for the Docker authentication step [deploy.py156-170](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/deploy.py#L156-L170):

```

```

Critical commands (build, push, deploy) cause abort on failure, while optional commands (repository creation) continue on error.

**Sources**: [src/praisonai/praisonai/deploy.py153-180](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/deploy.py#L153-L180)

## Development Environment

```

```

**Title**: Development Environment Components and Dependencies

### UV Package Manager

PraisonAI uses UV for fast dependency installation. UV is a Rust-based Python package manager that provides:

- Fast Resolution : ~10-100x faster than pip for dependency resolution
- Lock File Support : Deterministic builds via uv.lock files
- Virtual Environment Management : Automatic venv creation and management

The development Docker image includes UV installation [Dockerfile.dev21-35](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/Dockerfile.dev#L21-L35):

```

```

**Sources**: [docker/Dockerfile.dev21-35](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.dev#L21-L35) [src/praisonai-agents/uv.lock1-12](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/uv.lock#L1-L12) [src/praisonai/uv.lock1-12](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/uv.lock#L1-L12)

### Local Development Setup

For local development without Docker:

```

```

The `[dev]` extra includes development dependencies [pyproject.toml140-144](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/pyproject.toml#L140-L144):

```

```

**Sources**: [src/praisonai/pyproject.toml140-144](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/pyproject.toml#L140-L144)

### Conda Environment for Training

Training features require a dedicated Conda environment due to specialized dependencies (Unsloth, CUDA libraries). The CLI checks for this environment [cli/main.py561-583](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L561-L583):

```

```

The training command runs within the Conda environment [cli/main.py604-613](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L604-L613):

```

```

**Sources**: [src/praisonai/praisonai/cli/main.py561-613](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/cli/main.py#L561-L613)

## Configuration Management

```

```

**Title**: Configuration Variable Resolution Hierarchy

### Environment Variable Resolution

PraisonAI uses a priority-based system for configuration resolution [cli/main.py224-232](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L224-L232):

**Model Name Priority**:

1. MODEL_NAME (highest priority)
2. OPENAI_MODEL_NAME
3. gpt-4o-mini (default)

```

```

**Base URL Priority**:

1. OPENAI_BASE_URL (OpenAI SDK standard)
2. OPENAI_API_BASE (legacy)
3. OLLAMA_API_BASE
4. https://api.openai.com/v1 (default)

```

```

**Sources**: [src/praisonai/praisonai/cli/main.py224-232](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/cli/main.py#L224-L232)

### config_list Structure

The `config_list` is a standardized configuration format compatible with AutoGen [cli/main.py235-242](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L235-L242):

```

```

This structure is used throughout the framework for LLM initialization and is passed to `AgentsGenerator` for agent creation.

**Sources**: [src/praisonai/praisonai/cli/main.py235-242](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/cli/main.py#L235-L242)

### Configuration Directory Management

Three environment variables control configuration file locations:

The CLI creates necessary directories before launching Chainlit [cli/main.py109-116](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L109-L116):

```

```

This ensures all configuration files are stored in a single location rather than cluttering the project root or home directory.

**Sources**: [src/praisonai/praisonai/cli/main.py109-116](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/cli/main.py#L109-L116) [docker/Dockerfile.ui26-29](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.ui#L26-L29) [docker/README.md60-67](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L60-L67)

## Package Management

```

```

**Title**: Package Dependency Structure and Optional Features

### Package Versions

PraisonAI consists of two main packages with independent versioning:

Version strings are managed in dedicated files:

- praisonai : version.py 1 - __version__ = "4.4.11"
- praisonaiagents : pyproject.toml 7 - version = "1.4.7"

**Sources**: [src/praisonai/pyproject.toml1-3](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/pyproject.toml#L1-L3) [src/praisonai-agents/pyproject.toml6-7](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/pyproject.toml#L6-L7) [src/praisonai/praisonai/version.py1](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/version.py#L1-L1)

### Installation Patterns

**Minimal Installation**:

```

```

Includes only core dependencies: pydantic, rich, litellm, PyYAML, mcp, typer

**Feature-Specific Installation**:

```

```

**Full Installation**:

```

```

Includes all UI, chat, API, and deployment features (excludes framework-specific extras)

**Sources**: [src/praisonai/pyproject.toml29-125](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/pyproject.toml#L29-L125)

### Optional Feature Groups

The package defines modular dependency groups for different use cases [pyproject.toml29-125](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/pyproject.toml#L29-L125):

For `praisonaiagents`, key feature groups include [pyproject.toml22-85](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/pyproject.toml#L22-L85):

**Sources**: [src/praisonai/pyproject.toml29-144](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/pyproject.toml#L29-L144) [src/praisonai-agents/pyproject.toml22-85](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/pyproject.toml#L22-L85)

## API Server Launch

```

```

**Title**: API Server Launch Mechanisms and Port Configuration

### Chainlit Server Launch

The UI and Chat commands launch Chainlit servers using lazy imports [cli/main.py106-119](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/cli/main.py#L106-L119):

```

```

Port configuration is handled via environment variables:

- UI Service : CHAINLIT_PORT=8082 , CHAINLIT_HOST=0.0.0.0
- Chat Service : CHAINLIT_PORT=8083 , CHAINLIT_HOST=0.0.0.0

**Sources**: [src/praisonai/praisonai/cli/main.py106-119](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/cli/main.py#L106-L119) [docker/Dockerfile.ui26-30](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.ui#L26-L30) [docker/Dockerfile.chat26-30](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile.chat#L26-L30)

### Gunicorn WSGI Server

For production API deployment, the Dockerfile uses Gunicorn [Dockerfile46](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/Dockerfile#L46-L46):

```

```

The `api.py` file is generated by `CloudDeployer.create_api_file()` [deploy.py64-90](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/deploy.py#L64-L90):

```

```

A health check endpoint is created if `api.py` doesn't exist [Dockerfile33-43](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/Dockerfile#L33-L43):

```

```

**Sources**: [docker/Dockerfile33-46](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile#L33-L46) [src/praisonai/praisonai/deploy.py64-90](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/praisonai/deploy.py#L64-L90)

### FastAPI Server Launch

For detailed information about FastAPI and MCP server launch mechanisms, including the `launch()` method and endpoint registration, see [API Server Launch](/MervinPraison/PraisonAI/9.4-api-server-launch).

The `praisonai[api]` feature group includes FastAPI dependencies [pyproject.toml37-42](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/pyproject.toml#L37-L42):

```

```

**Sources**: [src/praisonai/pyproject.toml37-42](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/pyproject.toml#L37-L42)

## Deployment Comparison

## Health Monitoring

All deployed services include health checks for reliability:

**Docker Health Checks** [README.md113-119](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L113-L119):

```

```

**API Health Endpoint** [Dockerfile36-40](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/Dockerfile#L36-L40):

```

```

**Chainlit Built-in Health**: Chainlit includes automatic health monitoring on its web interface ports.

**Sources**: [docker/README.md113-119](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L113-L119) [docker/Dockerfile33-43](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/Dockerfile#L33-L43)

## Troubleshooting

### Common Deployment Issues

**Port Conflicts**:

```

```

**Environment Variables Not Loading**:

```

```

**Permission Issues**:

```

```

**Service Won't Start**:

```

```

**Sources**: [docker/README.md169-205](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/docker/README.md?plain=1#L169-L205)
