The Pi at the end of the tunnel

The Pi at the end of the tunnel

Atmo has reached Beta!

Last week v0.1.0 of Atmo was tagged, joining the other Suborbital projects in the land of beta. This is a big release, so I want to share some highlights about what's changed. Then to demonstrate what this new version can do, I want to show Atmo working alongside the Inlets Pro cloud native tunnel on Raspberry Pi.

For anyone new to Suborbital, Atmo is a framework and platform for building cloud native applications using WebAssembly. It is designed to enable boilerplate free, security-first, high performance web service development using a variety of languages. You can learn all about it here. Let's dive into the beta release!

Multi-arch support

Atmo now supports arm64! With the release of Reactr a few weeks ago, the core job scheduler and its WebAssembly runtime now support multiple architectures, and by upgrading Atmo to this new version, arm64 is now officially supported. With that brings multi-arch Docker images available from Docker Hub at suborbital/atmo. Running Atmo on AWS Graviton2 and Raspberry Pi is now quick and easy.

Static file API

Atmo, Reactr, and Subo now all support adding static files to your Runnable Bundles, and the Runnable API now provides the ability to access those files via a read-only filesystem. This allows Atmo to handle new use-cases such as serving static websites and accessing assets or templates needed to run your application. The static directory in your Atmo project will automatically be pulled into the Bundle when running subo build . --bundle, and those files are available with the new file::get_static() method in the Runnable API v0.6.3.

Improved performance

Along with the ability to run on multiple architectures, the update to Reactr also brought with it the latest version of Wasmer, which greatly improves the performance of your Runnables. Both raw compute performance and memory usage have been improved due to this upgrade and some internal architecture tweaks.

If you want to see performance benchmarks for all of the popular WebAssembly runtimes as of Q1 2021, check out this project from Frank Denis

Improved Swift language stability

Internal improvements to the Swift Runnable API library were made, bringing Swift support closer to stable! There are still a few more steps to be taken here, but the improvements are promising.

Expanded documentation

The Runnable API is now fully documented, which makes developing applications with Atmo that much easier! Further documentation improvements were made to make getting started with Atmo easier.

Overall this is a really exciting release, and we'd love to hear your thoughts by reaching out on Twitter, or via our GitHub discussions. For a tutorial that shows how to get Atmo up and running on arm64, read on.

Let's get up and running on Raspberry Pi

To showcase the beta release, I thought it would be fun to show how to get Atmo up and running on Raspberry Pi and then use the Inlets Pro tunnel to make the service available on the internet. The new 0.8.0 release of Inlets Pro allows creating automatic TLS certificates with LetsEncrypt, which makes exposing an Atmo service from the Raspberry Pi on your desk super easy.

To try out Inlets Pro, you'll need a license. You can get a 14 day trial on that page! I recommend the license, it's a very useful tool to have at your disposal.

Next up, we need to install the beta 64-bit version of Raspbian onto the Raspberry Pi, since the usual release is 32-bit! This will involve wiping your Pi's SD card, so don't do this if you have a Pi setup you don't want to lose! You can also use a spare SD card if you just want to try things out, of course.

I won't go through the whole process here, but you can find the instructions and links you need on this forum post.

Once you have the Raspberry Pi updated and set up, let's install Docker:

curl -sSL https://get.docker.com | sh

There is official support for arm64 and Raspberry Pi!

Get your Atmo application running

Now that we've got the Pi set up to run Atmo, let's build a Runnable Bundle on your local machine. In an Atmo project (use important-api if you need a demo app), use Subo to build:

subo build . --bundle

Docker is used to build bundles unless you have your local toolchains set up for WebAssembly. In that case you can pass --native to bypass Docker.

Now we can push the Bundle to your Pi:

scp ./runnables.wasm.zip pi@$PI_ADDRESS:/home/pi

And then use Docker on the Pi to run Atmo with your Bundle.

docker run -v $PWD:/home/atmo -e ATMO_HTTP_PORT=8080 -p 8080:8080 suborbital/atmo:v0.1.0 atmo

Add -d if you want to run in detached mode (so it'll stay running when you exit the SSH session)

Your application will start up, and you can make requests to it! If you're using the important-api demo, give this a try:

curl $PI_ADDRESS:8080/stars/suborbital/atmo

Neat. Now, let's get the network tunnel set up so we can serve this to the world.

Create the tunnel

To start, you'll need a virtual machine running somewhere in the cloud. I suggest using DigitalOcean, as their $5/mo Droplet works beautifully for this purpose.

If you want a more detailed set of instructions for Inlets Pro, Alex Ellis has you covered.

Log into your remote instance and install Inlets Pro:

wget https://github.com/inlets/inlets-pro/releases/download/0.8.0/inlets-pro

Create yourself a token:

export TOKEN=$(head -c 16 /dev/urandom | shasum | cut -d" " -f1)

Set the following environment variables. You'll need to set up a DNS record for a domain you own and the public IP address of the cloud VM you set up.

export DOMAIN={domain you set up}
export EMAIL={your email}
export PUBLIC_IP={public IP of server}

And then start the Inlets server:

./inlets-pro http server \
  --letsencrypt-domain $DOMAIN \
  --letsencrypt-email $EMAIL \
  --letsencrypt-issuer prod \
  --token $TOKEN \
  --auto-tls \
  --tls-san $PUBLIC_IP

Now you can install and run the Inlets client on your Raspberry Pi. Make sure you set the $PUBLIC_IP and $TOKEN variables with the same values as the server, and create the LICENSE.txt file from your Inlets Pro license (or trial license).

wget https://github.com/inlets/inlets-pro/releases/download/0.8.0/inlets-pro-arm64
./inlets-pro-arm64 http client \
    --url wss://$PUBLIC_IP:8123 \
    --token $TOKEN \
    --license-file ./LICENSE.txt \
    --upstream http://127.0.0.1:8080

And just like that, your service is live! Make a request to the HTTPS address of the domain you set up, and watch the cloud native WebAssembly + network tunnel magic at work.

postman_raspberry_pi.jpg

I think this is a really awesome showcase of what Atmo can do. The goal is for it to feel just as natural on small devices as well as huge compute clusters. I hope you'll give Atmo a try and let us know how it goes.

As always, check out suborbital.dev for all the information about Suborbital's projects, check out the Atmo site for full documentation, and reach out to me on Twitter if you have any questions. Subscribe to the Launch Pad newsletter below for occasional updates about Suborbital and the cloud native WebAssembly space.

Cover photo by Ray Hennessy from Unsplash