WebAssembly is an extremely promising new technology that’s getting a lot of interest from Microsoft’s cloud-native computing teams, both in its Deis Labs subsidiary and in Azure. With new WebAssembly tools arriving rapidly, what’s needed is an environment where you can try them out.
That’s why Deis Labs’ release of its new Hippo WebAssembly platform is so important. Built like many of Deis’ tools to scratch its own itch, it’s a way of quickly installing, managing, and running WebAssembly (WASM) code, whether it’s browser hosted or stand-alone WebAssembly System Interface (WASI). Using its built-in channels in conjunction with a Git server, you can make and deploy different releases in one environment, keeping production, staging, and development builds separate while still only needing one Hippo server.
You can host multiple applications in Hippo. WebAssembly means they’re sandboxed by default, requiring explicit permissions to access the host system or external devices. Your code is also portable. Once compiled for WebAssembly, it’ll run on any WebAssembly system, whether Windows, Linux, or macOS, or whether Intel, RISC-V, or ARM. Hippo gives you a way to build once, test once, and run your code anywhere.
Setting up Hippo on a development PC
Although tools like Hippo would be ideal for cloud-native operations, the current developer release has only been tested on desktop systems. I decided to try it out on a Windows PC running a recent build of WSL2, hosting Ubuntu. Deis provides instructions for running Hippo locally, with details for macOS and Linux systems.
There were some issues getting the prerequisites in place to run Hippo on a WSL2 Ubuntu 20.04 LTS system. First, I needed to install WAGI, the WebAssembly Application Gateway Interface. This installs easily enough, with a single binary in the downloadable tarfile hosted in its GitHub repo. Once download, unpacked, and moved to a user binary directory, it ran easily. I took the opportunity to install Rust, as I might need it if I had to recompile any of the Deis tools.
This step was perhaps the most difficult on WSL2, as it required a copy of the build-essential toolkit. Ubuntu 20.04 doesn’t have the right set of dependencies for this, so I needed an alternative package installer that would allow me to downgrade certain key libraries to the appropriate versions. A Stack Overflow answer pointed me to aptitude, an alternative to apt that allows you to choose appropriate dependencies for an install and allow it to replace two low-level C libraries. I finally got build-essential installed, ready for Rust, using its setup scripts.
What is Bindle?
The main reason for installing Rust as part of a Hippo installation is for Bindle, Deis’ WebAssembly packaging tool. Bindle is described as an “aggregate object storage” system. The metaphor its documentation uses is that “Bindle is the digital silverware drawer.” We may all have some different objects in our silverware drawer, but we all use the drawer to sort and store silverware. Bindle does much the same for the artifacts that make up a modern application while providing a level of understanding of how applications are composed, based on how and where they’re used.
You can have a Bindle description of an application that contains elements needed for a sparse installation on a resource-constrained edge host (like a Raspberry Pi) and for a high-powered server at the heart of a public cloud. A Bindle client in an application host can take the elements and dependencies and deploy them appropriately. The result is an application-centric deployment model that avoids multiple builds using repositories and smart descriptions to deliver the right code to the right environment.
Once Bindle is installed, you can run it, using the defaults to set up a local Bindle server ready for Hippo to use. Next, I installed node.js, using the WSL instructions provided by Microsoft. This entailed using curl to download nvm, then running it to install both the most recent and long-term support versions of node. Don’t use the Ubuntu instructions for installing node; they use a snap to install it, and snaps are not well supported in WSL2.
You’ll need to install Rust’s wasm32-wasi support for any Hippo-hosted Rust WebAssembly applications, as well as the yo-wasm Yeoman application scaffolding tools. This will allow you to compile Rust code to a WASI target, ready to run inside Hippo.
With those in place, I could now install .NET 5, first setting up support for Microsoft’s Debian package repositories before installing both the .NET 5 SDK and runtime. You have two options for .NET runtimes: one with ASP.NET Core support and one without. As Hippo is a model-view-controller web application, you should use the ASP.NET version of the runtime.
Building and running Hippo
Once all the prerequisites have been installed, you can build Hippo. Start by cloning the Hippo GitHub repository into a local directory in your WSL system. Once it’s installed, you can build and run the app, pointing it your local Bindle server by adding a BINDLE_URL environment variable. It’s a good idea to install Hippo’s CLI at this point, as it’s necessary for application development and deployment.
You can now connect to your Hippo server to test that it’s working. You should find it on localhost on port 5001. If you’re running a recent build of WSL 2, you should be able to connect to it from a Windows desktop browser using localhost, as Microsoft has finally fixed one of WSL 2’s long-standing networking problems, proxying its virtual machine networking through Windows while still preserving its own IP address and virtual network switch. There’s no longer any need for scripts to extract and share network addresses.
Before you can connect to the server, you will need to register an account. As it’s running locally, you can choose any account details you like; just be sure they’re something you can remember since you’ll need the details to build your first app. Once you’ve created an account, log in. You’re taken to a Your Apps page with a Create New Application button.
Creating your first Hippo WebAssembly app
Although you can build apps for Hippo from the web UI, it’s easier for now to use the command line. Make sure you have the Hippo CLI installed, as Yeoman will use it to build application scaffolding for you. Before you start, set environment variables for your Hippo account and password as well as for its endpoints. Yes, this isn’t good security practice, but here we’re just building and running test code on an isolated PC using software that’s not yet ready for production.
To build a basic hello world application, use the yo-wasm tools to build a WebAssembly Rust application. If you follow the script and enter the appropriate values, this will build and load source code into your Hippo server. Next use the Rust cargo tool to compile and test your WASI application. Once you’ve got it running on the command line, you can use Hippo’s CLI tool to push it to Bindle where it will be visible inside Hippo. Open the project, select your build’s development environment, and click on the link to run your code.
There’s a lot to like in Hippo. If there’s one thing that’s been missing from WebAssembly, it’s an effective Heroku-like playground to help you get started. Hippo may not be that playground yet, but it’s certainly one you can use as part of your own development workflow now, even in its early stage. Being able to run it on a development PC is an added advantage, as there’s no need to rely on third-party systems. It’s low enough impact that it can be run as part of a WSL 2 environment, so you can take advantage of tools like Visual Studio Code, working with its remote development features to edit Rust code in WSL from Windows.
If you’re interested in WebAssembly, Hippo may well be the tool you need to get started. It makes working with WebAssembly code simpler, bringing many of the different pieces needed to run a development into one place. Although it’s still clearly an early release, there’s enough here to let you get started, making it an essential tool for anyone working with WebAssembly.