Skip to main content
CLI Proxy API supports multiple storage backends for configuration and authentication data, enabling distributed and cloud-native deployments.

Overview

By default, CLI Proxy API stores configuration and OAuth tokens in local files. For production deployments, you can use:
  • PostgreSQL - Centralized database storage
  • Git - Version-controlled configuration with remote repository sync
  • Object Storage - S3-compatible object storage
Storage backends are mutually exclusive. If multiple backends are configured, PostgreSQL takes precedence, followed by Object Storage, then Git.

PostgreSQL Store

Store configuration and authentication data in a PostgreSQL database.

Configuration

Set environment variables:
.env

Database Schema

The PostgreSQL store automatically creates two tables:

Config Table

Auth Table

Docker Compose Example

docker-compose.yml

Connection String Format

Examples:

How It Works

The PostgreSQL store:
  1. Initialization (cmd/server/main.go:243-266):
    • Connects to PostgreSQL using the provided DSN
    • Creates schema and tables if they don’t exist
    • Bootstraps configuration from example or database
  2. Mirroring (internal/store/postgresstore.go:146-158):
    • Syncs configuration from database to local workspace
    • Mirrors auth files to local directory for file-based operations
    • Maintains bidirectional sync between database and filesystem
  3. Persistence (internal/store/postgresstore.go:188-260):
    • Saves auth metadata to local files
    • Upserts records to database with timestamps
    • Handles updates and deletions

Git Store

Store configuration and authentication data in a Git repository with automatic sync.

Configuration

Set environment variables:
.env

Repository Structure

Docker Compose Example

docker-compose.yml

Git Authentication

GitHub Personal Access Token

  1. Generate a token at https://github.com/settings/tokens
  2. Required scopes: repo (full control of private repositories)
  3. Use token as GITSTORE_GIT_TOKEN

GitLab Personal Access Token

  1. Generate at Settings → Access Tokens
  2. Required scopes: read_repository, write_repository
  3. Use oauth2 as username

Bitbucket App Password

  1. Generate at Account Settings → App passwords
  2. Required permissions: repository:write

How It Works

The Git store:
  1. Initialization (internal/store/gitstore.go:92-213):
    • Clones the repository if not present
    • Pulls latest changes from remote
    • Creates directory structure if empty
  2. Auto-commit (internal/store/gitstore.go:556-628):
    • Commits changes to local repository
    • Rewrites history as single commit (squash)
    • Force pushes to remote
  3. File Operations (internal/store/gitstore.go:216-296):
    • Saves auth files locally
    • Stages and commits changes
    • Pushes to remote repository
The Git store uses force push (--force) to maintain a clean history. Do not manually edit the repository or use it for other purposes.

Object Store

Store configuration and authentication data in S3-compatible object storage.

Configuration

Set environment variables:
.env

Endpoint Format

The endpoint supports both HTTP and HTTPS:
The server automatically:
  • Parses the scheme to determine SSL usage
  • Uses path-style bucket access for compatibility
  • Handles endpoint URL parsing (cmd/server/main.go:276-302)

Provider Examples

AWS S3

Or use regional endpoint:

MinIO

docker-compose.yml

Cloudflare R2

DigitalOcean Spaces

Google Cloud Storage (S3 Compatible)

Object Structure

Objects are stored with the following keys:

How It Works

The object store:
  1. Initialization (internal/store/objectstore.go:54-119):
    • Creates MinIO client with endpoint and credentials
    • Ensures bucket exists (creates if needed)
    • Syncs objects to local workspace
  2. Mirroring (internal/store/objectstore.go:388-438):
    • Downloads all objects from bucket
    • Writes to local directory structure
    • Maintains local cache for file operations
  3. Upload (internal/store/objectstore.go:440-460):
    • Reads local file changes
    • Uploads to object storage with content type
    • Handles deletions by removing objects

Storage Backend Priority

When multiple backends are configured, the following priority applies (cmd/server/main.go:237-455):
  1. PostgreSQL - If PGSTORE_DSN is set
  2. Object Storage - If OBJECTSTORE_ENDPOINT is set and PostgreSQL is not configured
  3. Git - If GITSTORE_GIT_URL is set and neither PostgreSQL nor Object Storage are configured
  4. Local Files - Default if no backend is configured

Comparison

Migration

From Local Files to PostgreSQL

  1. Start with local file configuration
  2. Set up PostgreSQL database
  3. Set PGSTORE_DSN environment variable
  4. Restart service - configuration is automatically migrated

From Local Files to Git

  1. Create a Git repository
  2. Set Git environment variables
  3. Restart service - files are committed and pushed

From Local Files to Object Storage

  1. Create an S3 bucket
  2. Set object storage environment variables
  3. Restart service - files are uploaded to bucket

Troubleshooting

PostgreSQL Connection Failed

Common issues:
  • Wrong credentials in PGSTORE_DSN
  • PostgreSQL not accepting connections
  • Firewall blocking port 5432

Git Push Failed

Common issues:
  • Invalid or expired token
  • Insufficient token permissions
  • Repository doesn’t exist
  • Force push disabled on branch

Object Storage Upload Failed

Common issues:
  • Wrong access key or secret key
  • Bucket doesn’t exist
  • Insufficient permissions
  • Endpoint URL incorrect

Next Steps

Docker Deployment

Deploy using Docker and Docker Compose

Cloud Deployment

Deploy in cloud environments with dynamic configuration