---
title: Self-Hosting
description: Host your own instance of Alita Robot.
---

This guide covers everything you need to deploy your own instance of Alita Robot.

## Prerequisites

Before you begin, ensure you have:

| Component | Minimum Version | Purpose |
|-----------|-----------------|---------|
| **PostgreSQL** | 16+ | Primary database |
| **Redis** | 7+ | Caching layer |
| **Docker** (recommended) | 20.10+ | Container deployment |

For building from source:
- **Go** 1.26+

## Deployment Options

:::tip[Quick Recommendation]
Docker Compose is the fastest way to get started. It bundles PostgreSQL and Redis so you do not need to install them separately.
:::

**[Docker Compose](/self-hosting/docker/)**

Recommended The easiest way to deploy Alita. Includes PostgreSQL and Redis out of the box.

```bash
git clone https://github.com/divkix/Alita_Robot.git
cd Alita_Robot
cp sample.env .env
# Set BOT_TOKEN, OWNER_ID, MESSAGE_DUMP, WEBHOOK_DOMAIN, WEBHOOK_SECRET in .env
docker compose up -d
```

**[Binary Deployment](/self-hosting/binary/)**

Download pre-built binaries for your platform:

- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64, arm64)

**[Build from Source](/self-hosting/source/)**

Compile the bot yourself for development or customization:

```bash
git clone https://github.com/divkix/Alita_Robot.git
cd Alita_Robot
go build -o alita_robot .
```

## Essential Configuration

At minimum, you need these environment variables:

```bash
BOT_TOKEN=your_bot_token_from_botfather
OWNER_ID=your_telegram_user_id
MESSAGE_DUMP=-100xxxxxxxxxx  # Log channel ID
DATABASE_URL=postgresql://alita:change-me@localhost:5432/alita
```

Redis itself is also required at runtime (only `DISABLE_CACHE=true`, a load-testing mode, starts without it, with Redis-backed features degraded). No Redis endpoint variable is needed
when it is available at the default `localhost:6379`; otherwise set either
`REDIS_ADDRESS=host:port` or a full `REDIS_URL`.

**[Full Environment Reference](/api-reference/environment/)**

Complete list of all environment variables and their descriptions.

## Webhook vs Polling

| Mode | Use Case | Setup Complexity |
|------|----------|------------------|
| **Webhook** | Production | Requires HTTPS domain |
| **Polling** | Development | Simple, works anywhere |

**[Webhook Setup](/self-hosting/webhooks/)**

Configure webhooks for production deployments.

## Database Setup

Alita uses PostgreSQL with automatic migrations:

```bash
# Enable auto-migration
AUTO_MIGRATE=true

# Or run manually (requires PSQL_DB_* env vars to be set)
make psql-migrate
```

**[Database Guide](/self-hosting/database/)**

Database setup, migrations, connection pooling, and schema design.

## Admin Panel (Mini App)

An optional Telegram Mini App dashboard is served by the same HTTP server under
`/panel`. It is off by default: with `PANEL_ENABLED` unset or `false`, `/panel`
and `/panel/api/v1/*` return 404, group `/settings` and `/help` add no dashboard
button, the menu button is left alone, and the bot behaves exactly as before.

Enable it with its public HTTPS URL, forward `/panel` from the reverse proxy and
restart:

```bash
PANEL_ENABLED=true
PANEL_PUBLIC_URL=https://bot.example.com/panel   # the URL Telegram opens
```

**[Admin Panel Guide](/self-hosting/admin-panel/)**

Environment variables, the HTTPS and reverse-proxy setup, the optional BotFather Mini App link, every entry point and the failure modes.

## Monitoring

Built-in observability endpoints:

- `GET /health` - Health check with DB/Redis status
- `GET /metrics` - Prometheus metrics (bearer-protected when `METRICS_AUTH_TOKEN` is set)
- `GET /db_metrics` - Database performance metrics (bearer-protected when `METRICS_AUTH_TOKEN` is set)

**[Monitoring Guide](/self-hosting/monitoring/)**

Health checks, Prometheus metrics, and resource monitoring.

## Next Steps

**[Docker Deployment](/self-hosting/docker/)**

Quick start with containers

**[Environment Variables](/api-reference/environment/)**

Full configuration reference

**[Troubleshooting](/self-hosting/troubleshooting/)**

Common issues and solutions
