InsForge: AI Backend-as-a-Service
InsForge is an open-source Backend-as-a-Service platform for AI coding agents, built around PostgreSQL. It provides authentication, database APIs, file storage, a model gateway, edge functions, site deployment, and payment integrations. These features reduce common backend implementation work.
Pigsty provides the app/insforge template. It runs stateless InsForge OSS services in Docker Compose and stores critical state in Pigsty-managed PostgreSQL. This provides high availability, backup and recovery, monitoring, ingress domains, and infrastructure services. The database does not depend on an ephemeral container volume.
The template targets InsForge OSS v2.3.3 and uses external PostgreSQL. It runs three services by default: InsForge Dashboard/API, PostgREST, and Deno Runtime. The latter two bind only to host loopback.
Quick Start
Run the following on a fresh Linux x86 / ARM server with a compatible operating system:
On a fresh deployment, run infra.yml first so node.yml can use its CA. Existing Pigsty deployments should retain their INFRA/ETCD inventory and avoid repeating initialization. See Database and Permissions for the utility library requirements on every database node.
After installation, the default access URLs are:
http://<your_ip_address>:7130http://isf.pigsty
The default administrator account is [email protected] / pigsty. In production, you must change the administrator account, administrator password, JWT secret, encryption key, and database password.
To access InsForge through isf.pigsty, add the following entry to /etc/hosts on the machine running your browser:
To expose the service to the public internet, use a real domain and HTTPS certificate, and modify infra_portal as described below.
Checklist
- Prepare a fresh Linux server with at least
2C4G; use an SSD/NVMe disk. - Confirm that the server has a static private IPv4 address and can access GHCR / Docker Hub, or that a registry mirror is configured.
- After running
./configure -c app/insforge, change the default passwords, domains, and keys inpigsty.yml. - Generate new
JWT_SECRETandENCRYPTION_KEYvalues separately withopenssl rand -base64 32. - Keep
POSTGRES_PASSWORDconsistent with the password ofdbuser_insforgeinpg_users. - For public access, configure a real domain, an HTTPS certificate, and firewall access rules.
- Install and preload
insforge_pg_utilson every PostgreSQL node, verify the extension packages, and runpig pb infoafter deployment.
Architecture
The InsForge template separates the database from the application containers by default:
Components:
- InsForge App:
ghcr.io/insforge/insforge-oss:v2.3.3, providing the Dashboard and main API on port7130. - PostgREST:
postgrest/postgrest:v12.2.12, generating REST APIs from PostgreSQL schemas; bound to127.0.0.1:5430on the host. - Deno Runtime:
denoland/deno:alpine-2.0.6, running the bundled, pinned function host and bound to127.0.0.1:7133on the host. - PostgreSQL: Managed by Pigsty for persistent state, backup, monitoring, and high availability.
Configuration Template
conf/app/insforge.yml defines a single-node, self-hosted InsForge template. The default topology includes:
insforge: The node running the InsForge, PostgREST, and Deno Runtime containers.pg-meta: The PostgreSQL database cluster managed by Pigsty, including the roles, database, and extensions required by InsForge.infra: Infrastructure services such as Nginx ingress, Grafana, and VictoriaMetrics.etcd: The distributed configuration store required by Patroni.
Key configuration excerpts:
Important Parameters
app.yml copies the app/insforge directory to /opt/insforge and uses apps.insforge.conf to override /opt/insforge/.env. Common parameters include:
| Parameter | Default | Description |
|---|---|---|
JWT_SECRET | Sample secret | JWT signing secret; must be replaced in production, preferably with a random value of at least 32 characters |
ENCRYPTION_KEY | Sample secret | Encrypts runtime credentials; must be replaced in production and managed separately from JWT_SECRET |
ROOT_ADMIN_USERNAME | [email protected] | Root administrator account |
ROOT_ADMIN_PASSWORD | pigsty | Root administrator password; must be replaced in production |
POSTGRES_HOST / POSTGRES_PORT | 10.10.10.10 / 5432 | Pigsty PostgreSQL endpoint |
POSTGRES_DB | insforge | InsForge database |
POSTGRES_USER | dbuser_insforge | Application user that connects InsForge to PostgreSQL |
POSTGRES_PASSWORD | DBUser.Insforge | Application user password; must be replaced in production |
INSFORGE_VERSION | v2.3.3 | InsForge OSS image tag |
DENO_RUNTIME_IMAGE | denoland/deno:alpine-2.0.6 | Full Deno Runtime image reference |
INSFORGE_IMAGE | Empty | Optional full app image override, taking precedence over INSFORGE_VERSION |
APP_PORT | 7130 | External InsForge App port |
POSTGREST_PORT | 5430 | PostgREST loopback port |
DENO_PORT | 7133 | Deno Runtime loopback port |
ACCESS_API_KEY | Empty | Optional MCP / API access key; generated by InsForge when empty |
ACCESS_ANON_KEY | Empty | Optional anonymous frontend access key; should begin with anon_ when set |
OPENROUTER_API_KEY | Empty | Optional OpenRouter model gateway key |
AWS_S3_BUCKET / S3_* | Empty | Optional object storage configuration |
DENO_DEPLOY_TOKEN | Empty | Optional Deno Deploy integration |
VERCEL_TOKEN / FLY_API_TOKEN | Empty | Optional site deployment and compute platform integrations |
STRIPE_* / RAZORPAY_* | Empty | Optional payment integrations |
Generate production secrets with:
When changing the database password, keep the application and database definitions synchronized. For example:
Once ENCRYPTION_KEY has been used for production data, keep it stable. Changing it may make stored runtime credentials such as API keys, OAuth tokens, and function secrets impossible to decrypt.
Database and Permissions
The default InsForge database is named insforge and owned by dbuser_insforge. The template creates the following roles:
| Role | Login | Purpose |
|---|---|---|
dbuser_insforge | Yes | Application user that connects InsForge to PostgreSQL; granted superuser in the template |
anon | No | PostgREST anonymous role |
authenticated | No | PostgREST authenticated-user role |
project_admin | No | Administrative role with service-key semantics and BYPASSRLS |
files/insforge.sql configures PostgREST role privileges, default privileges, ACLs for project_admin, and the helper function public.reload_postgrest_schema(). The function executes:
This notifies PostgREST to reload its schema.
insforge_pg_utils is a required PostgreSQL utility library. It lets project_admin manage RLS policies on managed tables and manage extensions; application migrations do not replace it. Copy the complete app/insforge/pgutils/ directory to every database node, install it before PostgreSQL initialization, and preload it through pg_libs. It exposes no SQL objects, so no CREATE EXTENSION is needed.
pgutils/install.sh downloads and verifies pinned official source, applies the PG16–18 compatibility patch, and builds it with PGXS. For PG18 on Debian/Ubuntu, use postgresql-server-dev-18 and /usr/lib/postgresql/18/bin/pg_config. On EL/RPM, use postgresql18-devel, gcc, make, curl, patch, and /usr/pgsql-18/bin/pg_config. The script does not change configuration or restart a cluster; plan preload configuration and restart separately for an existing deployment.
cron.use_background_workers: true runs scheduled jobs as background workers without adding a loopback trust rule. Reserve enough max_worker_processes slots for cron, replication, and other extensions.
Service Ports and Persistence
The default Docker Compose services are:
| Service | Container | Host Port | Description |
|---|---|---|---|
| InsForge App | insforge | 7130 | Dashboard and main API |
| PostgREST | insforge-postgrest | 127.0.0.1:5430 | Automatically generated REST API |
| Deno Runtime | insforge-deno | 127.0.0.1:7133 | Edge function runtime |
Remote clients use the main InsForge API for data and functions; do not expose PostgREST or Deno directly. The Docker compute provider is optional, and the template does not mount the Docker socket by default. Enabling that mount grants the container root-equivalent access to the host.
The default Docker volumes are:
| Volume | Mount Point | Description |
|---|---|---|
storage-data | /insforge-storage | Local file storage |
insforge-logs | /insforge-logs | Application logs |
deno_cache | /deno-dir | Deno module cache |
By default, Docker containers connect to the Pigsty node at 10.10.10.10:5432. The template HBA rule permits 172.16.0.0/12, covering Docker’s default bridge and common custom bridge networks.
Domain and Ingress
The template adds an InsForge entry to infra_portal by default:
To use a real domain such as insforge.example.com, replace the placeholder in bulk:
Then apply the Nginx ingress configuration:
Before requesting an HTTPS certificate, verify that the domain resolves to the current node. Then add or update certbot under infra_portal.insforge:
Then run:
Operations
InsForge is installed in /opt/insforge. Common commands include:
Upgrade to v2.3.3
Before upgrading, back up PostgreSQL, including system.migrations, file storage, and deployment overrides. Preserve the existing JWT and credential-encryption keys. After you pull the new image and recreate the InsForge container, its startup migration runner applies and records 065_restrict-http-extension-to-admin.
This migration revokes PUBLIC EXECUTE on 13 outbound HTTP and curl-option function signatures from the http extension while retaining project_admin execution. This prevents normal users and anonymous API keys from invoking them through RPC. The new-install files/insforge.sql baseline includes the same restriction. Do not replay the full baseline on an existing database or run a separate copy of migration 065 manually.
After upgrading, check the migration ledger and actual function privileges. The defaults should be anon=false, authenticated=false, and project_admin=true. Custom role memberships or explicit grants can still confer additional access. See the template upgrade checks and official migration.
Offline Deployment
For offline environments, save the images in advance:
The first Deno startup needs access to deno.land and registry.npmjs.org to pre-cache the function host and worker dependencies. The SDK is pinned to @insforge/[email protected], and functions/deno.lock fixes the dependency graph. Configure DENO_HTTP_PROXY / DENO_HTTPS_PROXY if needed. make save archives images only, not the deno_cache volume; prepare and transfer that cache separately for offline use.
Default artifact locations:
/tmp/docker/insforge/postgrest.tgz/tmp/docker/insforge/insforge.tgz/tmp/docker/insforge/deno.tgz/tmp/insforge.tgz
Load the images on the target machine:
Data and Backup
InsForge state is divided into two categories:
- Business data, users, project metadata, permissions, and related state are stored in the Pigsty PostgreSQL database
insforge. - Local files and logs are stored in the Docker volumes
storage-dataandinsforge-logs.
By default, the template schedules a full PostgreSQL backup every day at 1:00 AM:
After deployment, check the backup status:
If file storage is configured to use S3 / MinIO, file objects are managed by that object storage system. If you keep local volumes, include them separately in your host-level backup strategy.
Troubleshooting
Check container status:
View logs:
Check whether PostgreSQL is reachable from the container:
Check whether the HBA rules include the Docker network:
Check whether the roles exist:
Check for port conflicts:
Common issues:
- Cannot log in: Verify
ROOT_ADMIN_USERNAME/ROOT_ADMIN_PASSWORDin/opt/insforge/.env. Check theinsforgecontainer logs. - PostgREST fails to start: Verify that
anon,authenticated, andproject_adminexist. Verify thatJWT_SECRETmatches the InsForge App setting. - Database connection fails: Verify
POSTGRES_HOST,POSTGRES_PORT, andPOSTGRES_PASSWORDagainstpg_users. Verify that HBA permits the Docker network. - File upload or download errors: When using S3 / MinIO, check
AWS_S3_BUCKET,S3_ENDPOINT_URL,S3_FORCE_PATH_STYLE, and the access-key configuration.
References
- InsForge project: https://github.com/InsForge/InsForge
- Pigsty template: https://github.com/pgsty/pigsty/blob/main/conf/app/insforge.yml
- Docker Compose: https://github.com/pgsty/pigsty/blob/main/app/insforge/docker-compose.yml
- Database baseline: https://github.com/pgsty/pigsty/blob/main/files/insforge.sql
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)