Skip to content

Local Docker setup

Spin up the server locally with one script. The setup brings up two containers — pia-server and a PostgreSQL database — and exposes the API at http://localhost:8080.

  • Docker Desktop with WSL integration enabled
  • Git Bash or a WSL terminal
FilePurpose
docker-compose.local.ymlCompose config for local deployment (server + PostgreSQL)
.env.exampleTemplate for the required environment variables
docker-local.shWrapper script for build / start / stop / logs / db

Two values must be present in .env. Without them the server refuses to start.

VariableWhat it isHow to generate
JWT_SECRET_KEYSigns auth tokens, any string ≥ 32 charsopenssl rand -hex 32
ENCRYPTION_MASTER_KEYEncrypts stored API keys, exactly 64 hex charsopenssl rand -hex 32

POSTGRES_PASSWORD is auto-generated on first run if not set.

The AI proxy needs at least one upstream provider to be useful.

VariableExample
AI_API_KEYsk-proj-...
AI_PROVIDERopenai or azure
AI_MODELgpt-4o-mini
AI_ENDPOINThttps://api.openai.com

You can also configure separate providers per client mode (Optimize / Assistant / Research). The client sends the active mode via the X-Pia-Mode header; if no per-mode override is set the default provider above is used.

VariablePurpose
AI_ASSISTANT_PROVIDER / _API_KEY / _MODEL / _ENDPOINTOverride for Assistant mode
AI_RESEARCH_PROVIDER / _API_KEY / _MODEL / _ENDPOINTOverride for Research mode

To enable Google or Microsoft sign-in locally:

VariableWhat it is
OAUTH_GOOGLE_CLIENT_ID / OAUTH_GOOGLE_CLIENT_SECRETGoogle OAuth credentials
OAUTH_MICROSOFT_CLIENT_ID / OAUTH_MICROSOFT_CLIENT_SECRETMicrosoft / Entra credentials
  1. Create .env from the template

    Terminal window
    cd /c/projects/Pia
    cp .env.example .env
  2. Generate and paste the keys

    Terminal window
    openssl rand -hex 32 # → JWT_SECRET_KEY
    openssl rand -hex 32 # → ENCRYPTION_MASTER_KEY

    Open .env and paste the values. Add AI_API_KEY if you want the AI proxy to work.

  3. Start everything

    Terminal window
    ./docker-local.sh

    The script builds the image, starts PostgreSQL, waits for it to be healthy, then starts pia-server. The API binds to localhost:8080; PostgreSQL to localhost:5432.

  4. Verify

    Terminal window
    curl http://localhost:8080/health
    # → {"status":"healthy","timestamp":"..."}

In Pia, open Settings → Cloud Sync and set:

SettingValue
Server URLhttp://localhost:8080

Then choose Pia Cloud as your AI provider. The client will route to the server for /api/ai/optimize, /api/sync/push, and /api/sync/pull.

OAuth login buttons in the client only appear when the corresponding OAUTH_* credentials are set in .env.

Terminal window
./docker-local.sh # Build and start
./docker-local.sh stop # Stop
./docker-local.sh restart # Restart
./docker-local.sh logs # Tail logs
./docker-local.sh db # psql shell into the local database
./docker-local.sh clean # Stop and delete the PostgreSQL data volume
  • Server won’t start: read ./docker-local.sh logs. Most often JWT_SECRET_KEY or ENCRYPTION_MASTER_KEY is missing or the wrong length.
  • PostgreSQL connection errors: run ./docker-local.sh db to confirm Postgres is reachable. If you switched from SQLite, run ./docker-local.sh clean to drop the old volume.
  • AI proxy returns 503: AI_API_KEY is missing. Check GET /api/ai/status.
  • OAuth not working: confirm the OAuth redirect URI http://localhost:8080/auth/callback (or /signin-microsoft for Entra) is registered with the provider, and that client ID + secret are in .env.