anfra docsAlpha
Self-hostCloud providers

Self-host on Heroku

Self-host anfra on Heroku with the container stack and the heroku CLI.

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 Heroku. Follow https://anfra.ai/docs/self-host/heroku.md. Do the steps you can, and tell me which ones I need to do.

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

Heroku builds the Dockerfile when you push, using the container stack and a heroku.yml file.

1. Add a Dockerfile and heroku.yml 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 \
  -O https://raw.githubusercontent.com/holistics/anfra-hosting/main/heroku.yml
git add Dockerfile .dockerignore heroku.yml
git commit -m "Add Dockerfile and heroku.yml"
git push

2. Create the app

heroku create
heroku stack:set container

heroku create prints the app's address, https://<app>-<id>.herokuapp.com. heroku info shows it again later.

3. Set config vars

heroku config:set \
  LOGIN_USERS='maria:a-long-password,agent:another-long-password' \
  ANFRA_DATA_SOURCES="$(cat .anfra/data_sources.yml)" \
  PUBLIC_URL=https://<app>-<id>.herokuapp.com

Your database credentials

Git leaves .anfra/data_sources.yml out, so this is how Heroku gets your database credentials. If your project only uses a DuckDB file in the repo, leave out the ANFRA_DATA_SOURCES line.

No PORT variable is needed: Heroku 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. Deploy

git push heroku main
heroku ps:scale web=1:basic

A Basic dyno has 512 MB of memory and doesn't sleep. Keep it at one dyno. With more, sign-in breaks.

5. Check that it works

Open https://<app>-<id>.herokuapp.com. 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 heroku logs --tail. 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.

6. Connect your coding agent

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

claude mcp add --transport http anfra https://<app>-<id>.herokuapp.com/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

Then run git push heroku main, or turn on automatic deploys in the app's Deploy tab.

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