Skip to main content

Self-Host InsForge on AWS EC2

This guide will walk you through self-hosting the InsForge platform on an AWS EC2 instance 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

  • AWS Account with EC2 access
  • Basic knowledge of SSH and command-line operations
  • Domain name (optional, for custom domain setup)

πŸš€ Deployment Steps

1. Create and Configure EC2 Instance

1.1 Launch EC2 Instance

  1. Log into AWS Console and navigate to EC2 Dashboard
  2. Click β€œLaunch Instance”
  3. Configure Instance:
    • Name: insforge-server (or your preferred name)
    • AMI: Ubuntu Server 24.04 LTS (HVM), SSD Volume Type
    • Instance Type: t3.medium or larger (minimum 2 vCPU, 4 GB RAM)
      • For production: t3.large (2 vCPU, 8 GB RAM) recommended
      • For testing: t3.small (2 vCPU, 2 GB RAM) minimum
    • Key Pair: Create new or select existing key pair (download and save the .pem file)
    • Storage: 30 GB gp3 (minimum 20 GB recommended)

1.2 Configure Security Group

Create or configure security group with the following inbound rules:
⚠️ Security Note: For production, restrict PostgreSQL (5432) to specific IP addresses or remove external access entirely. Consider using a reverse proxy (nginx) and exposing only ports 80/443.
  1. Navigate to Elastic IPs in EC2 Dashboard
  2. Click Allocate Elastic IP address
  3. Associate the Elastic IP with your instance
This ensures your instance keeps the same IP address even after restarts.

2. Connect to Your EC2 Instance

3. Install Dependencies

3.1 Update System Packages

3.2 Install Docker

3.3 Add Your User to Docker Group

After installing Docker, you need to add your user to the docker group to run Docker commands without sudo:
Verify it works:
πŸ’‘ Note: If docker ps doesn’t work immediately, log out and log back in via SSH, then try again.
⚠️ Security Note: Adding a user to the docker group grants them root-equivalent privileges on the system. This is acceptable for single-user environments like your EC2 instance, but be cautious on shared systems.

3.4 Install Git

4. Deploy InsForge

4.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.

4.2 Create Environment Configuration

The secrets are already generated β€” leave them as they are. Set the URL browsers will use:
Optional, all off by default:
.env.example carries every remaining variable with its defaults.
πŸ’‘ Back up .env somewhere safe. Its secrets are what let you migrate or restore this instance.

4.3 Start InsForge Services

Press Ctrl+C to exit log view.

4.4 Verify Services

5. Access Your InsForge Instance

5.1 Test Backend API

Expected response:

5.2 Access Dashboard

Open your browser and navigate to:
Log in with the ROOT_ADMIN_USERNAME and ROOT_ADMIN_PASSWORD you set in .env.

6.1 Update DNS Records

Add DNS A records pointing to your EC2 Elastic IP:

6.2 Install Nginx Reverse Proxy

Create Nginx configuration:
Add the following configuration:
Enable the configuration:
Update your .env file with HTTPS URLs:
Change:
Restart services:

πŸ”§ Management & Maintenance

View Logs

Stop Services

Restart Services

Update InsForge

An update is a pull and restart β€” but the checkout matters too: the stack reads Postgres’s configuration and the Deno functions from it. Run this from ~/insforge:

Backup Database

Run these from ~/insforge:

Monitor Resources

πŸ› Troubleshooting

Services Won’t Start

Cannot Connect to Database

Port Already in Use

Out of Memory

Consider upgrading to a larger instance type:

SSL Certificate Issues

πŸ“Š Performance Optimization

For Production Workloads

  1. Upgrade Instance Type: Use t3.large or t3.xlarge
  2. Enable Auto-scaling: Set up Application Load Balancer with auto-scaling groups
  3. Use RDS: Migrate from containerized PostgreSQL to AWS RDS for better reliability
  4. Enable CloudWatch: Monitor metrics and set up alarms
  5. Configure Backups: Set up automated daily backups
  6. Use S3 for Storage: Configure S3 bucket for file uploads instead of local storage

Database Optimization

πŸ”’ Security Best Practices

  1. Change Default Passwords: Update admin and database passwords
  2. Enable Firewall: Use AWS Security Groups effectively
  3. Regular Updates: Keep system and Docker images updated
  4. SSL/TLS: Always use HTTPS in production
  5. Backup Regularly: Automate database backups
  6. Monitor Logs: Set up log monitoring and alerts
  7. Limit SSH Access: Restrict SSH to specific IP addresses
  8. Use IAM Roles: Instead of AWS access keys where possible

πŸ†˜ Support & Resources

πŸ“ Cost Estimation

Monthly AWS Costs (approximate):
πŸ’‘ Cost Optimization: Use AWS Savings Plans or Reserved Instances for long-term deployments to save up to 70%.

Congratulations! πŸŽ‰ Your InsForge instance is now running on AWS EC2. You can start building applications by connecting AI agents to your backend platform. For other production deployment strategies, check out our deployment guides.