Skip to main content

๐Ÿ“– Self-Hosting InsForge on Azure Virtual Machines (Extended Guide)

This guide provides comprehensive, step-by-step instructions for self-hosting, managing, and securing the InsForge platform on an Azure Virtual Machine (VM) using Docker Compose.
This deploys InsForge itself, not the app you built. If you just want to take your app live, use Sites instead. This guide is for running the InsForge backend on your own infrastructure.
This cloud walkthrough is community-maintained and can lag the latest InsForge release. The canonical, always-current setup is the deploy/docker-compose/ directory in the InsForge repo.

Prerequisites

  • An active Azure account.
  • An SSH client to connect to the virtual machine.
  • Basic familiarity with the Linux command line.

Step 1: ๐Ÿ–ฅ๏ธ Create an Azure Virtual Machine

  1. Log in to the Azure Portal and navigate to Virtual machines.
  2. Click + Create > Azure virtual machine.
  3. Basics Tab:
    • Resource Group: Create a new one (e.g., insforge-rg).
    • Virtual machine name: insforge-vm.
    • Image: Ubuntu Server 22.04 LTS or newer.
    • Size: Standard_B2s (2 vCPUs, 4 GiB memory) is a good start. For production, consider Standard_B4ms (4 vCPUs, 16 GiB memory).
    • Authentication type: SSH public key.
    • SSH public key source: Generate new key pair. Name it insforge-key.
  4. Networking Tab:
    • In the Network security group section, click Create new.
    • Add the following inbound port rules to allow traffic:
      • 22 (SSH)
      • 80 (HTTP for Nginx)
      • 443 (HTTPS for Nginx/SSL)
      • 7130 (InsForge API and dashboard)
  5. Review and Create:
    • Click Review + create, then Create.
    • When prompted, Download private key and create resource. Save the .pem file securely.
    • Once deployed, find and copy your VMโ€™s Public IP address.

Step 2: โš™๏ธ Connect and Set Up the Server

  1. Connect via SSH: Open your terminal, give your key the correct permissions, and connect to the VM.
  2. Update System Packages:
  3. Install Docker: Follow the official, up-to-date instructions on the Docker website to install Docker Engine on Ubuntu: https://docs.docker.com/engine/install/ubuntu/
  4. Add Your User to the Docker Group: This step allows you to run Docker commands without sudo.
    Verify it works. This command should now run without sudo:
    ๐Ÿ’ก Note: If docker ps doesnโ€™t work, log out of your SSH session and log back in, then try again. โš ๏ธ Security Note: Adding a user to the docker group grants them root-equivalent privileges. This is acceptable for a single-user VM but be cautious on shared systems.
  5. Install Git:

Step 3: ๐Ÿš€ Deploy InsForge

  1. Get the Repository:
    Checks out the files the stack reads and generates JWT_SECRET, ENCRYPTION_KEY, ROOT_ADMIN_PASSWORD and POSTGRES_PASSWORD into .env. Nothing is started.
  2. Create Environment Configuration: The secrets are already generated โ€” leave them as they are. Point the API URLs at your VM.
    The rest of .env.example covers optional features (OpenRouter, Vercel deployments, OAuth providers). Leave those blank unless you need them.
    Back up .env somewhere safe. Its secrets are what let you migrate or restore this instance.
  3. Start InsForge Services: Pull the Docker images and start all services in the background.
  4. Verify Services: Check that all four containers are running.
    You should see the postgres, postgrest, insforge, and deno services running.

Step 4: ๐Ÿ”‘ Access Your InsForge Instance

  1. Test Backend API: Use curl to check the health endpoint.
    You should see a response like: {"status":"ok", ...}
  2. Access Dashboard: Open your browser and navigate to: http://<your-vm-public-ip>:7130 Log in with the ROOT_ADMIN_USERNAME and ROOT_ADMIN_PASSWORD you set in your .env file.

  1. Update DNS Records: In your domain providerโ€™s DNS settings, add two A records pointing to your VMโ€™s Public IP address:
    • api.yourdomain.com โ†’ <your-vm-public-ip>
    • app.yourdomain.com โ†’ <your-vm-public-ip>
  2. Install and Configure Nginx as a Reverse Proxy:
    Paste the following configuration:
    Enable the configuration and reload Nginx:
  3. Install SSL Certificate with Certbot:
    Follow the prompts. Certbot will handle the rest.
  4. Update .env with HTTPS URLs: Edit your .env file and update the URLs.
    Change the URLs to https:
    Restart the services for the changes to take effect:

๐Ÿ”ง Management & Maintenance

  • View Logs: docker compose logs -f (all services) or docker compose logs -f insforge (specific service).
  • Stop Services: docker compose down
  • Restart Services: docker compose restart
  • Update InsForge: Run these from ~/insforge. The images are prebuilt, so pull the latest tags instead of rebuilding.
  • Backup Database: Run from ~/insforge.

๐Ÿ› Troubleshooting

  • Services Wonโ€™t Start: Check docker compose logs for errors. Ensure you have enough disk space (df -h) and memory (free -h).
  • Port Already in Use: Check which process is using the port with sudo netstat -tulpn | grep :7130.
  • Out of Memory: Consider upgrading your Azure VM to a size with more RAM.

๐Ÿ“Š Cost Estimation

Disclaimer: Prices are estimates based on Pay-As-You-Go rates in a common region (e.g., East US) and can vary. Always check the official Azure Pricing Calculator for the most accurate information. On Azure, you pay for the VMโ€™s resources (CPU, RAM, Storage), which are shared by all the Docker services you run on it.

Free Tier (for Testing)

  • Cost: ~$0/month for the first 12 months.
  • Resources: Azure provides a free tier that includes 750 hours/month of a B1s burstable VM.
  • Limitations: This VM has very limited resources (1 vCPU, 1 GiB RAM) and may run slowly. Itโ€™s suitable only for basic testing and familiarization, not for active development or production.

Starter Setup (for Development & Small Projects)

  • Cost: ~30โˆ’30 - 40/month
  • Resources: This estimate is for a Standard_B2s VM (2 vCPU, 4 GiB RAM) running all the InsForge Docker containers.
  • Breakdown: The cost primarily consists of the VM compute hours. It also includes the OS disk storage and a static public IP address. This single VM runs your database, backend, Deno, and all other services.

Production Setup (for Scalability & Reliability)

For production, you can choose between an all-in-one, larger VM or a more robust setup using managed services.
  • Option A: All-in-One Larger VM
    • Cost: ~150โˆ’150 - 170/month
    • Resources: A more powerful Standard_B4ms VM (4 vCPU, 16 GiB RAM) to handle higher traffic and all services.
    • Pros: Simple to manage, consolidated cost.
    • Cons: Database and application share resources, which can create performance bottlenecks. Scaling requires upgrading the entire VM.
  • Option B: Managed Services (Recommended for Production)
    • Cost: ~$120+/month (highly variable)
    • Resources:
      • Application VM: A Standard_B2s VM for the app services (InsForge, PostgREST, Deno). (~$30/month)
      • Managed Database: Use Azure Database for PostgreSQL for reliability, automated backups, and scaling. (~$40+/month for a starter tier)
    • Pros: Highly reliable and scalable. Database performance is isolated and guaranteed. Managed backups and security.
    • Cons: More complex setup, costs are distributed across multiple services.

๐Ÿ”’ Security Best Practices

  • Change Default Passwords: Always update admin and database passwords.
  • Enable Firewall: Use Azure Network Security Groups (NSGs) to restrict access to necessary ports and IP addresses.
  • Regular Updates: Periodically run sudo apt update && sudo apt upgrade -y and update InsForge.
  • Backup Regularly: Automate database and configuration backups.