Self-host on Fly.io
Self-host anfra on Fly.io from the dashboard or the fly CLI.
Set up with a coding agent
Self-host this anfra project on Fly.io. Follow https://anfra.ai/docs/self-host/fly.md. Do the steps you can, and tell me which ones I need to do.You need your project on GitHub (how) and a Fly.io account.
Fly.io runs the container as Firecracker VMs close to your users, with optional scale-to-zero.
Fly needs three pieces of configuration the other platforms don't: memory (the default 256 MB machine is too small), one machine (Fly starts two by default, and sign-in breaks across two), and PUBLIC_URL (Fly doesn't tell the container its address). Fly doesn't provide PORT either, so the image listens on its default 8080.
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 push2. Deploy
In the dashboard, click Launch an App, choose Launch an App from GitHub, and select the project's repo, granting Fly access if prompted.
Click Customize deploy and set:
- Internal port:
8080 - Memory: at least 512 MB
- Environment Variables:
LOGIN_USERS(details),ANFRA_DATA_SOURCES(the contents of your.anfra/data_sources.yml), andPUBLIC_URL(https://<app-name>.fly.dev)
Deploy, then run fly scale count 1 to keep a single machine. Optionally enable Auto Deploy under Deployments > Settings so pushes to the default branch redeploy automatically.
Your database credentials
Git leaves .anfra/data_sources.yml out, so ANFRA_DATA_SOURCES is how Fly.io gets your database credentials. If your project only uses a DuckDB file in the repo, leave it out.
To let people sign in with Google or GitHub instead, or to use your own login such as Tailscale or Cloudflare Access, see Authentication.
3. Check that it works
Open https://<app-name>.fly.dev. 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 fly 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.
4. Connect your coding agent
In Claude Code, with your address and the agent user's password:
claude mcp add --transport http anfra https://<app-name>.fly.dev/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 pushWith Auto Deploy on, Fly.io deploys it on its own. Otherwise, run fly deploy.
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 pushIt deploys like any change to your project. Run anfra update too, so your CLI matches.