Skip to content

Deploying xmlu‐helper (aka sqlite‐server) on ec2

Jon Udell edited this page Feb 13, 2025 · 1 revision

Deploying an XMLUI helper service on AWS EC2

This guide helps you deploy a basic XMLUI helper service on AWS EC2.

When do I need to deploy?

You might not need to!

XMLUI is happy to run on your local machine. Use it that way to prototype and develop apps. If you want to share your prototype, you can use a tool like Tailscale to temporarily expose your local machine to the internet, or just to your team.

This deployment guide assumes you have an app you want to put into production.

What is the helper service and why might I need it?

You might not need it!

A basic XMLUI app can run from an S3 bucket with no extra support, see the guide for basic S3 hosting with no extra support. You'll need a helper service for one or both of these reasons:

  • Your app uses SQL to read from and/or write to a database.

  • Your app needs to read from and/or write to an API that does not support CORS.

We provide a lightweight open source server that enables both. It's a single binary that you can easily copy into any deployment. It embeds SQLite, and defaults to a file, data.db, that you can also easily deploy. You can go a long way with SQLite! But if you want to use your own database, the server's /query endpoint can be adjusted to point to it. Similarly the CORS proxy (the /proxy) endpoint can be adjusted to point to your own service if desired.

What else do I need?

An XMLUI minimally comprises:

├── Main.xmlui
├── index.html
└── xmlui
    └── xmlui-standalone.umd.js

This structure can live anywhere: your local machine, a web server, S3, etc. If you want to host it on S3 see []

🔀 Deployment paths for helper service

Depending on your experience level and permissions, there are a variety of deployment paths, follow the one that best matches your access level. If unsure, check with your admin!

I am OK with SSH and allowed to provision an EC2 instance

Details
  • You will create the EC2 instance and set up SSH access.
  • You will manually upload and run the server.

Steps

  1. Log into AWS and go to EC2 Dashboard.

  2. Launch a new EC2 instance:

    • Choose Amazon Linux 2 or Ubuntu 22.04.
    • Select instance type t3.micro (or similar).
    • Create a Security Group allowing:
      • SSH (22) (Your IP only)
      • TCP (8080) (Open to the web for API access).
    • Create a key pair and download the .pem file. chmod 400 the file.
    • Click Launch.
  3. Connect via SSH:

    ssh -i your-key.pem ec2-user@your-ec2-public-ip
    • Replace your-key.pem with your key file.
    • Replace your-ec2-public-ip with the actual public IP.
  4. Upload and run your server:

    scp -i your-key.pem xmlui-helper data.db ec2-user@your-ec2-public-ip:~
    ssh -i your-key.pem ec2-user@your-ec2-public-ip
    chmod +x xmlui-helper
    ./xmlui-helper  # to observe console
    
    or 
    
     tmux new -s xmlui   # Use `tmux` or to keep the process alive:
     ./xmlui-helper

    (Press Ctrl+B, then D to detach, and tmux attach -t xmlui to reattach)

    (Can alternatively use screen)

  5. (Optional) Set up a domain in Route 53:

    • Go to Route 53 → Hosted Zones.
    • Create an A record pointing to your EC2 instance's public IP.
    • Wait for DNS propagation.
  6. Access your server:

    • If using the raw URL: http://your-ec2-public-ip:8080
    • If using a domain (optional): http://your-domain.com:8080

I am OK with SSH but my admin has to provision an EC2 instance

Details

I am OK with SSH but my admin has to provision an EC2 instance

Details

I am OK using CloudFormation to provision an EC2 instance, and allowed to do so

Details

I want my admin to use CloudFormation to provision an EC2 instance on my behalf

Details

I am OK with the AWS console, and allowed to provision an EC2 instance

Details

I am OK with the AWS console but my admin has to provision an EC2 instance on my behalf

Details

Decision tree

graph TD;
    A[Business Dev] -->|Prefers SSH| B[Can create EC2?];
    A -->|Prefers AWS Console| C[Can create EC2?];

    B -->|Yes| D[Allowed to use CloudFormation?];
    B -->|No| E[Admin provisions EC2, Dev uses SSH];

    C -->|Yes| F[Allowed to use CloudFormation?];
    C -->|No| G[Admin provisions EC2, Dev uses Console];

    D -->|Yes| H[Dev provisions EC2 via CloudFormation & uses SSH];
    D -->|No| I[Dev provisions EC2 manually & uses SSH];

    F -->|Yes| J[Dev provisions EC2 via CloudFormation & uses Console];
    F -->|No| K[Dev provisions EC2 manually & uses Console];

    E --> L[Deploy XMLUI Server via SSH];
    G --> M[Deploy XMLUI Server via Console];
    H --> N[Deploy XMLUI Server via SSH];
    I --> O[Deploy XMLUI Server via SSH];
    J --> P[Deploy XMLUI Server via Console];
    K --> Q[Deploy XMLUI Server via Console];

    style A fill:#f9f,stroke:#333,stroke-width:2px;
    style B fill:#bbf,stroke:#333,stroke-width:2px;
    style C fill:#bbf,stroke:#333,stroke-width:2px;
    style D fill:#ffb,stroke:#333,stroke-width:2px;
    style E fill:#ffb,stroke:#333,stroke-width:2px;
    style F fill:#ffb,stroke:#333,stroke-width:2px;
    style G fill:#ffb,stroke:#333,stroke-width:2px;
    style H fill:#bfb,stroke:#333,stroke-width:2px;
    style I fill:#bfb,stroke:#333,stroke-width:2px;
    style J fill:#bfb,stroke:#333,stroke-width:2px;
    style K fill:#bfb,stroke:#333,stroke-width:2px;

    style L fill:#add8e6,stroke:#333,stroke-width:1px;
    style M fill:#add8e6,stroke:#333,stroke-width:1px;
    style N fill:#add8e6,stroke:#333,stroke-width:1px;
    style O fill:#add8e6,stroke:#333,stroke-width:1px;
    style P fill:#add8e6,stroke:#333,stroke-width:1px;
    style Q fill:#add8e6,stroke:#333,stroke-width:1px;

Loading