DEV Community

Cover image for Running an Arweave Gateway on GitHub Codespaces
K for Fullstack Frontend

Posted on • Edited on

Running an Arweave Gateway on GitHub Codespaces

It's nice to have the important pieces of your architecture run on your local machine when developing. It lowers latency for requests and helps debugging errors. With the release of the AR.IO gateway, we can now run an Arweave gateway with a small resource footprint. This guide will explain how to run the AR.IO gateway on GitHub Codespaces.

Target Audience

This guide assumes you know how to use GitHub (e.g., creating a repository and starting a Codespace) and how to use the command line on Linux.

Prerequisites

We need a GitHub account to create a repository and run a Codespace.

Creating a Repository on GitHub

First, we need to create a new repository on GitHub. We give it a name like "arweave-gateway", set the "Add a README file" checkbox to ensure the repository isn't empty after creation (this allows us to start a Codespace right away), and click the "Create Repository" button.

Starting a Codespace for the Repository

After we create the repository, GitHub will redirect us directly to it. There, we have to click the "Code" button, choose the "Codespaces" tab, and click" Create Codespace".

Preparing the Codespace for the Gateway Installation

A codespace runs on Ubuntu pre-installed with many useful development tools, but we need to get these tools up-to-date and ensure we have the right Node.js version. For this, we run the following commands:

$ sudo apt update
$ sudo apt upgrade
$ nvm install 16.15.1
Enter fullscreen mode Exit fullscreen mode

Installing the AR.IO Gateway

We start by cloning the ar-io/ar-io-node repository from GitHub with this command:

$ gh repo clone ar-io/ar-io-node
Enter fullscreen mode Exit fullscreen mode

Configuring the Gateway

Next, we need to configure the gateway by creating a new file at ar-io-node/.env with the following content:

GRAPHQL_HOST=arweave.net
GRAPHQL_PORT=443
START_HEIGHT=1000000
Enter fullscreen mode Exit fullscreen mode

Building the Gateway

Now that we configured everything, we can run the build command inside the ar-io-node directory:

$ sudo docker-compose up -d --build
Enter fullscreen mode Exit fullscreen mode

After it finishes (it can take a few minutes), Docker-Compose automatically starts a cluster with two containers. One is an Envoy proxy (running on port 3000) that relays requests from outside the cluster to the other container (running on port 4000), which is our AR.IO gateway that will handle the requests.

Testing the Gateway

After the gateway starts, our codespace will show us a small popup that lets us open the server running on port 3000 in the browser.

Interesting URLs we can use to test the gateway:

The gateway info page:

https://<CODESPACE_SUBDOMAIN>-3000.app.github.dev/info
Enter fullscreen mode Exit fullscreen mode

The TX of the Universal Data License:

https://<CODESPACE_SUBDOMAIN>-3000.app.github.dev/tx/yRj4a5KMctX_uOmKWCFJIjmY8DeJcusVk6-HzLiM_t8
Enter fullscreen mode Exit fullscreen mode

The website of the Universal Data License:

https://<CODESPACE_SUBDOMAIN>-3000.app.github.dev/yRj4a5KMctX_uOmKWCFJIjmY8DeJcusVk6-HzLiM_t8
Enter fullscreen mode Exit fullscreen mode

Again, we must replace <CODESPACE_SUBDOMAIN> with our actual subdomain.

Summary

The AR.IO gateway is a lightweight implementation of an Arweave gateway suitable for many purposes. It even runs on a Raspberry PI if we can trust its creators!

Since GitHub Codespaces runs Ubuntu and comes pre-installed with most of the gateway's dependencies, getting up and running is just a question of a few minutes. After that, we can enjoy the low latency of our very own Arweave gateway.

Top comments (0)