anfra docsAlpha
Self-hostCloud providers

Self-host on Railway

Self-host anfra on Railway from a GitHub repo.

Set up with a coding agent

Paste this prompt into your coding agent, and it helps you set this up.
Self-host this anfra project on Railway. Follow https://anfra.ai/docs/self-host/railway.md. Do the steps you can, and tell me which ones I need to do.

You need your project on GitHub (how) and a Railway account.

Railway builds the Dockerfile from a connected repo.

1. Add a Dockerfile to your project

From your project's folder, run:

curl -fsSL -O https://raw.githubusercontent.com/holistics/anfra-hosting/main/Dockerfile \
  -O https://raw.githubusercontent.com/holistics/anfra-hosting/main/.dockerignore
git add Dockerfile .dockerignore
git commit -m "Add Dockerfile"
git push

2. Create the service

In the Railway dashboard: New Project > Deploy from GitHub repo, and select the project's repo. Railway detects the Dockerfile automatically.

On the service, open Settings. Under Networking, click Generate Domain. Under Deploy, set the Healthcheck Path to /health.

3. Set service variables

On the service, open the Variables tab and add:

  • LOGIN_USERS: who can sign in, as name:password pairs (details)
  • ANFRA_DATA_SOURCES: the contents of your .anfra/data_sources.yml
  • PUBLIC_URL: https://${{RAILWAY_PUBLIC_DOMAIN}}, which Railway fills with the domain from step 2

Your database credentials

Git leaves .anfra/data_sources.yml out, so ANFRA_DATA_SOURCES is how Railway gets your database credentials. Skip it if your project only uses a DuckDB file in the repo.

Use plain service variables. Shared variables are for referencing values across multiple services. Mark secrets as sealed to hide their values after saving. No PORT variable is needed: Railway provides one and the image binds to it automatically.

To let people sign in with Google or GitHub instead, or to use your own login such as Tailscale or Cloudflare Access, see Authentication.

4. Check that it works

Open the domain from step 2, https://<name>.up.railway.app. You see a login page. Sign in with a user from LOGIN_USERS, and open one of your Data Apps: it shows your data.

If it doesn't start, read the logs with the service's Deployments tab, View logs. The last line starting with start.sh: says what to fix, see Troubleshooting. If your apps show errors instead of data, anfra can't reach your database: check your database credentials, and your database's IP allowlist.

5. Connect your coding agent

In Claude Code, with your address and the agent user's password:

claude mcp add --transport http anfra https://<name>.up.railway.app/mcp \
  --header "Authorization: Basic $(printf 'agent:<agent-password>' | base64 | tr -d '\n')"

Ask it to list your datasets and run a small query. For other agents, see Coding agents with MCP.

Updates

Your anfra project

When you change your project, such as a new or edited Data App, model or dataset, commit it and push it:

git add .
git commit -m "Add the sales dashboard"
git push

Railway deploys it on its own, within a few minutes.

anfra

Your Dockerfile pins the anfra version. To move to the latest one, download it again from your project's folder, and push it:

curl -fsSL -O https://raw.githubusercontent.com/holistics/anfra-hosting/main/Dockerfile
git add Dockerfile
git commit -m "Update anfra"
git push

It deploys like any change to your project. Run anfra update too, so your CLI matches.

On this page