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
| Variable | Description | Required | Default |
|---|---|---|---|
PGSTORE_DSN | PostgreSQL connection string | Yes | (none) |
PGSTORE_SCHEMA | Database schema name | No | public |
PGSTORE_LOCAL_PATH | Local mirror directory | No | ./pgstore |
Database Schema
The PostgreSQL store automatically creates two tables:Config Table
Auth Table
Docker Compose Example
docker-compose.yml
Connection String Format
How It Works
The PostgreSQL store:-
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
-
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
-
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
| Variable | Description | Required | Default |
|---|---|---|---|
GITSTORE_GIT_URL | Git repository URL | Yes | (none) |
GITSTORE_GIT_USERNAME | Git username | No | git |
GITSTORE_GIT_TOKEN | Personal access token or password | Yes | (none) |
GITSTORE_LOCAL_PATH | Local clone directory | No | ./gitstore |
Repository Structure
Docker Compose Example
docker-compose.yml
Git Authentication
GitHub Personal Access Token
- Generate a token at https://github.com/settings/tokens
- Required scopes:
repo(full control of private repositories) - Use token as
GITSTORE_GIT_TOKEN
GitLab Personal Access Token
- Generate at Settings → Access Tokens
- Required scopes:
read_repository,write_repository - Use
oauth2as username
Bitbucket App Password
- Generate at Account Settings → App passwords
- Required permissions:
repository:write
How It Works
The Git store:-
Initialization (
internal/store/gitstore.go:92-213):- Clones the repository if not present
- Pulls latest changes from remote
- Creates directory structure if empty
-
Auto-commit (
internal/store/gitstore.go:556-628):- Commits changes to local repository
- Rewrites history as single commit (squash)
- Force pushes to remote
-
File Operations (
internal/store/gitstore.go:216-296):- Saves auth files locally
- Stages and commits changes
- Pushes to remote repository
Object Store
Store configuration and authentication data in S3-compatible object storage.Configuration
Set environment variables:.env
| Variable | Description | Required | Default |
|---|---|---|---|
OBJECTSTORE_ENDPOINT | S3-compatible endpoint URL | Yes | (none) |
OBJECTSTORE_BUCKET | Bucket name | Yes | (none) |
OBJECTSTORE_ACCESS_KEY | Access key ID | Yes | (none) |
OBJECTSTORE_SECRET_KEY | Secret access key | Yes | (none) |
OBJECTSTORE_LOCAL_PATH | Local mirror directory | No | ./objectstore |
Endpoint Format
The endpoint supports both HTTP and HTTPS:- 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
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:-
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
-
Mirroring (
internal/store/objectstore.go:388-438):- Downloads all objects from bucket
- Writes to local directory structure
- Maintains local cache for file operations
-
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):
- PostgreSQL - If
PGSTORE_DSNis set - Object Storage - If
OBJECTSTORE_ENDPOINTis set and PostgreSQL is not configured - Git - If
GITSTORE_GIT_URLis set and neither PostgreSQL nor Object Storage are configured - Local Files - Default if no backend is configured
Comparison
| Feature | PostgreSQL | Git | Object Storage | Local Files |
|---|---|---|---|---|
| Distributed | ✅ | ✅ | ✅ | ❌ |
| Version Control | ❌ | ✅ | ❌ | ❌ |
| Transaction Support | ✅ | ❌ | ❌ | ❌ |
| Scalability | High | Medium | High | Low |
| Setup Complexity | Medium | Low | Low | None |
| Cost | Medium | Free (GitHub) | Low-Medium | Free |
| Best For | Production | Small teams | Cloud-native | Development |
Migration
From Local Files to PostgreSQL
- Start with local file configuration
- Set up PostgreSQL database
- Set
PGSTORE_DSNenvironment variable - Restart service - configuration is automatically migrated
From Local Files to Git
- Create a Git repository
- Set Git environment variables
- Restart service - files are committed and pushed
From Local Files to Object Storage
- Create an S3 bucket
- Set object storage environment variables
- Restart service - files are uploaded to bucket
Troubleshooting
PostgreSQL Connection Failed
- Wrong credentials in
PGSTORE_DSN - PostgreSQL not accepting connections
- Firewall blocking port 5432
Git Push Failed
- Invalid or expired token
- Insufficient token permissions
- Repository doesn’t exist
- Force push disabled on branch
Object Storage Upload Failed
- 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