Guide to Deploying Applications to Akash DeCloud
By: Wilson Louie
Tags: Deployment, Blockchain, Decentralized Cloud, Cloud Computing, Akash Network

Prerequisites

This guide should work for Mac users, (most) Linux users, and maybe for Windows users (see supported platforms). This guide also assumes basic command line comfortability and some familiarity with Docker.

The Docker image used in this guide is available here under the username wlouie1 , but if you want to create one yourself, you will need to install Docker and have an account on Docker Hub.

To deploy to Akash DeCloud, you will need to:

Install Akash. Choose Your Akash Network. We will be using edgenet, which is the Testnet with deployment capabilities that will reflect their next Mainnet version. Fund Your Account with Akash Tokens (AKTs), to pay for deployment. For edgenet, Akash provides an AKT faucet to fund test deployments.

Containerizing your Application

(The Docker image for the application described in this section is available here, so feel free to skip straight to the Deploying to Akash section below.)

Writing the Application

For demonstration purposes, we’ll use this web application that enables exploring UFO sightings around the world:

UFO Sightings Around the World, 1906–2014. Image by Author

Clone the application by:



cd UFO-Sightings/ git clone https://github.com/wlouie1/UFO-Sightings.git cd UFO-Sightings/

As you can see, the application consists purely of static HTML/Javascript/CSS files. If you were to start up a server locally, e.g. with the following if you have Python 3 installed:

python -m http.server 8000

then you can navigate to http://localhost:8000 and view the application.

Containerizing with Docker

Since all we need is a server to serve the static files of our web application, we can create a simple Docker image that bundles our static files with a web server such as Nginx.

Inside the UFO-Sightings directory, create a file called Dockerfile with the following content:

FROM nginx:alpine

COPY . /usr/share/nginx/html

Build the Docker image (we’ll name it ufo-data-vis and tag it as latest for simplicity; beware of the “latest” tag in practice though) via:

docker build -t ufo-data-vis:latest .

To test it, run the image as a container, with the host’s port 80 forwarded to the container’s port 80 (default port of Nginx):

docker run -p 80:80 ufo-data-vis:latest

If everything works, you should be able to view the application at http://localhost:80 .

Push Image to Docker Registry

Once we have a built Docker image, we need to make it publicly available so that the Akash deployment process can pull the image (private containers support is on their roadmap). If you have a Docker Hub account with username USERNAME , create a repository called ufo-data-vis , and then tag and push the image with:

docker tag ufo-data-vis:latest USERNAME/ufo-data-vis:latest

docker push USERNAME/ufo-data-vis:latest

..and we’re done! The Docker image representing our containerized application is now publicly available, and we can move on to deployment to Akash.

Consider the Docker Compose File

Deploying to Akash involves writing a Stack Definition Language (SDL) file that defines the deployment configuration (more details in the Create Deployment Configuration section below). The SDL documentation is here. You may notice that the SDL format is extremely similar to that of a Docker Compose file!

If we were to construct a Docker Compose file that utilizes the public Docker image of our web application, it would look something like this:

version: "3.8"

services:

web:

image: USERNAME/ufo-data-vis:latest

ports:

- "80:80"

To verify, you can save this file as docker-compose.yml under the UFO-Sightings directory, and run the container using docker-compose (make sure to stop any previously running container):

docker-compose up --build

and navigate to http://localhost:80 to confirm.

As you’ll see in the Create Deployment Configuration section, writing the SDL file essentially becomes a direct translation.