Hosting
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
cd
into your Micro-Rollup repository- Login to
fly.io
fly auth signup
fly auth login # if you are already logged in
- Copy this
fly.toml
file into your root directory.
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.
- 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
- Create a fly volume to persist your rollup's state.
fly volume create my_rollup -r atl -n 1
- Change your
.env
file to pointDATABASE_URI
to the fly volume's mount point.
DATABASE_URI="/data/db.sqlite"
- Import your
.env
file intofly.io
.
cat .env | fly secrets import
- 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
cd
into your Micro-Rollup repository- Change your
stackr.config.ts
to usepostgres
as the database. Railway supports Postgres and MySQL. - Install PostgreSQL client
npm install pg --save
- Copy this
railway.json
file into your root directory.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "./Dockerfile"
},
"deploy": {
"runtime": "V2",
"numReplicas": 1,
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
- Commit and push your changes to GitHub.
- 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
. - When your project canvas opens, on the right, start adding variables from your
.env
file. (Copy-pasting with the raw editor is faster) - For the
DATABASE_URI
variable, use the value:
DATABASE_URI=${{Postgres.DATABASE_URL}}
- Now, click on the
Create
button on the top right and create a new Postgres database service. - Once the DB service is created, your micro-rollup should be visually connected to the DB service.
- 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
- Follow this guide to spin up an EC2 instance with Docker enabled.
- 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! 🛼