Deploying Statusphere to Railway from Tangled

Saw some discussion today about how to deploy Atproto apps for the less backend/DevOps-inclined. Railway seemed pretty popular, and I've been meaning to try it myself, so let's see what damage we can do.

The absolute easiest way to deploy your first Atproto app is by using the Railway template @samuel.bsky.team created -- it only requires a couple of clicks!

Deploy atproto statusphere app

Deploy atproto statusphere app on Railway with one click, start for free. A minimal demo of an end-to-end atproto application

This is the first in a multi-part series:

1. Deploying statusphere-react to Railway via CLI (you're here)

2. Automating Railway deployments via Tangled/Spindle

1. Clone statusphere-react

You can either clone the repo as-is for this tutorial, or you can fork it and clone your fork.

@samuel.bsky.team/statusphere-react

the statusphere demo reworked into a vite/react app in a monorepo

2. Install Railway CLI

Check the docs for how to install the Railway CLI for your platform . For the Nix folks, there's a nixpkg .

3. Log in to Railway

I'm assuming you've already gone to https://railway.app and made an account.

Navigate to your statusphere-react directory, and then run the following:

railway login

Check out the CLI login docs if something goes wrong here.

4. Create a new project

A Project is the top-level resource for organizing your app. Run the following, and give your project a name if you like:

railway init

5. Create a new service

Next, a Service is an instance of your app. We're going to first create an empty service, so we can configure our environment variables later.

Run the following, and select "Empty Service" when prompted. Don't worry about setting variables, or setting a name if you don't want to:

railway add

6. Create a domain

To properly configure our OAuth client, we'll need a domain.

Railway makes getting a service-specific domain easy; save this value and hold on to it for later:

railway domain

7. Set up a volume

A volume ensures that our database persists between deployments and restarts.

Let's make one with the following command, and specify /persistent as the mount path when prompted:

railway volume add

8. Set our environment variables

Okay, we should have everything we need now to deploy very own statusphere.

We can set all of our basics at once:

railway variables \
--set NODE_ENV="production" \
--set PORT="8080" \
--set DB_PATH="../../../persistent/data.sqlite"

We'll set our COOKIE_SECRET to a randomly-generated 32-character value:

railway variables --set COOKIE_SECRET=$(openssl rand -base64 32)

Finally, we'll set our PUBLIC_URL and HOST to that domain we generated earlier. For HOST, remove the protocol from the domain (https://). Make sure that neither value contains trailing slashes (/):

railway variables \
--set PUBLIC_URL="<your url>" \
--set HOST="<your url minus protocol>"

9. Deploy!

Okay, we should be all good to go. Running the following command will deploy our app, and follow along with the logs:

railway up

That wraps it all up! You should be able to navigate to your domain, sign in to your account, and watch the statuses roll in.

Now that we've done all the setup and heavy lifting, CI/CD on Tangled should be a breeze. I'll update this Leaflet with a link once I'm done.