Skip to content

Hosting

How to host your Micro-Rollup

Your Micro-rollup comes with a pre-configured Dockerfile. This can be used to host it on many popular cloud platforms.

Using Fly.io

Fly.io is a cloud platform that allows developers to deploy and run applications globally. It offers a simple and efficient way to host web applications, including Micro-Rollups.

Prerequisites

Steps

  1. cd into your Micro-Rollup repository
  2. Login to fly.io
Terminal
fly auth signup
fly auth login # if you are already logged in
  1. Copy this fly.toml file into your root directory.
fly.toml
app = '<name>'
primary_region = 'atl'
 
[build]
 
[[mounts]]
  source = 'my_rollup'
  destination = '/data'
 
[http_service]
  internal_port = 3210
  force_https = true
  auto_stop_machines = 'off'
  auto_start_machines = true
  min_machines_running = 1
  processes = ['app']
 
[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

Make sure to replace <name> with your app name, and feel free to change the other settings as you see fit.

  1. Launch your app without deploying it.
fly launch --no-deploy

Answer 'yes' to copy config for a new app.

? Would you like to copy its configuration to the new app? Y
  1. Create a fly volume to persist your rollup's state.
fly volume create my_rollup -r atl -n 1
  1. Change your .env file to point DATABASE_URI to the fly volume's mount point.
.env
DATABASE_URI="/data/db.sqlite"
  1. Import your .env file into fly.io.
cat .env | fly secrets import
  1. Now, deploy your rollup!
fly deploy

Using Railway

Railway is a modern cloud platform that offers an easy and efficient way to deploy, manage, and scale applications. It provides a seamless experience for hosting various types of projects, including Micro-Rollups.

Prerequisites

  • Repo hosted on GitHub

Steps

  1. cd into your Micro-Rollup repository
  2. Change your stackr.config.ts to use postgres as the database. Railway supports Postgres and MySQL.
  3. Install PostgreSQL client
Terminal
npm install pg --save
  1. Copy this railway.json file into your root directory.
railway.json
{
    "$schema": "https://railway.app/railway.schema.json",
    "build": {
        "builder": "DOCKERFILE",
        "dockerfilePath": "./Dockerfile"
    },
    "deploy": {
        "runtime": "V2",
        "numReplicas": 1,
        "sleepApplication": false,
        "restartPolicyType": "ON_FAILURE",
        "restartPolicyMaxRetries": 10
    }
}
  1. Commit and push your changes to GitHub.
  2. Log into your Railway account and link your GitHub repository by following this guide. Do not deploy your project yet. Instead choose the option to Add variables.
  3. When your project canvas opens, on the right, start adding variables from your .env file. (Copy-pasting with the raw editor is faster)
  4. For the DATABASE_URI variable, use the value:
DATABASE_URI=${{Postgres.DATABASE_URL}}
  1. Now, click on the Create button on the top right and create a new Postgres database service.
  2. Once the DB service is created, your micro-rollup should be visually connected to the DB service.
  3. Deploy your project with all the new changes.

Using EC2

Amazon EC2 (Elastic Compute Cloud) is a web service that provides secure, resizable compute capacity in the cloud.

Prerequisites

  • An AWS account
  • Basic knowledge of AWS services
  • SSH client (for connecting to your EC2 instance)

Steps

  1. Follow this guide to spin up an EC2 instance with Docker enabled.
  2. Build and run your rollup's docker container by following the instructions here.

Hosting tips

  • Check your .env to make sure your variables are set properly and pointing to our Sepolia network.
  • Check your stackr.config.ts to make sure you are not deploying in Sandbox mode.
  • Next step could be to create a custom domain and point it to your hosted instance.

Feel free to contact the Stackr team if you have any questions. Happy rolling! 🛼