Skip to content

Self-Hosting

You can run the full Pia stack on your own infrastructure using Docker Compose.

  • Docker and Docker Compose
  • A domain with DNS configured
  • 1 GB RAM minimum
  1. Clone the repository:
Terminal window
git clone https://github.com/Pia-Ai-dev/Pia.git
cd Pia
  1. Copy and configure the environment file:
Terminal window
cp .env.example .env.prod
  1. Set the required environment variables in .env.prod:
JWT_SECRET_KEY=<generate-a-random-64-char-string>
ENCRYPTION_MASTER_KEY=<generate-a-random-64-char-string>
POSTGRES_PASSWORD=<strong-password>
  1. Start the services:
Terminal window
docker compose -f docker-compose.prod.yml up -d

The production stack consists of:

ServiceImagePortPurpose
Caddycaddy:2-alpine80, 443Reverse proxy + auto HTTPS
Pia Serverghcr.io/pia-ai-dev/pia-server8080API server
PostgreSQLpostgres:17-alpine5432Database

Update the Caddyfile with your domain:

your-domain.com {
reverse_proxy pia-server:8080
}

Caddy handles TLS certificate provisioning automatically via Let’s Encrypt.

Terminal window
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d