Self-host on AWS
Self-host anfra on Amazon Lightsail container services with the aws CLI.
Set up with a coding agent
Self-host this anfra project on AWS Lightsail. Follow https://anfra.ai/docs/self-host/aws.md. Do the steps you can, and tell me which ones I need to do.You need your project on GitHub (how) and a AWS account.
Amazon Lightsail container services run one container at a flat price. Lightsail doesn't build from GitHub: you build the image on your machine and push it.
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. Create the container service
aws lightsail create-container-service --service-name anfra --power nano --scale 1nano has 512 MB of memory. Wait until aws lightsail get-container-services --service-name anfra shows the state READY, and note its url.
3. Build and push the image
docker build -t anfra-project .
aws lightsail push-container-image --service-name anfra --label app --image anfra-projectPushing needs the Lightsail Control plugin.
4. Deploy
Write the container settings to a file outside git, with jq, so the line breaks in your credentials are kept:
jq -n --rawfile ds .anfra/data_sources.yml '{app: {
image: ":anfra.app.latest",
ports: {"8080": "HTTP"},
environment: {
ANFRA_DATA_SOURCES: $ds,
LOGIN_USERS: "maria:a-long-password,agent:another-long-password",
PUBLIC_URL: "<the service url, without the trailing slash>"
}}}' > ~/anfra-containers.json
aws lightsail create-container-service-deployment --service-name anfra \
--containers file://$HOME/anfra-containers.json \
--public-endpoint '{"containerName":"app","containerPort":8080,"healthCheck":{"path":"/health"}}'Your database credentials
The image leaves .anfra/data_sources.yml out, so this is how Lightsail gets your database credentials. If your project only uses a DuckDB file in the repo, leave out --rawfile ds .anfra/data_sources.yml and the ANFRA_DATA_SOURCES line.
To let people sign in with Google or GitHub instead, or to use your own login such as Tailscale or Cloudflare Access, see Authentication.
5. Check that it works
Open the service's url. 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 aws lightsail get-container-log --service-name anfra --container-name app. 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://<your-address>/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 pushThen run steps 3 and 4 again: build and push the image, then deploy it.
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.