Self-hosting
The same Sastra, on your own server.
Sastra is free software under the AGPL-3.0. Sastra Cloud sells the running of it. If you would rather run it yourself, here is how.
An example install with Docker Compose. The same commands are in the steps below.
What you need
Six pieces. Five are needed.
Tick what you already have. The Compose bundle brings the database and the scheduler for you.
of 5 needed pieces ready
Choose how to run it
Three ways to run Sastra.
Docker Compose
Run Postgres on your server
Get the two files.
mkdir sastra && cd sastra curl -fsSLO https://raw.githubusercontent.com/Sastra-Cloud/sastra/main/deploy/compose/docker-compose.yml curl -fsSL https://raw.githubusercontent.com/Sastra-Cloud/sastra/main/deploy/compose/.env.example -o .envFill in
.env.Set
POSTGRES_PASSWORD,BETTER_AUTH_URL,BETTER_AUTH_SECRET,AUTH_PROVISIONING_SECRET,CRON_SECRETandAPP_ENCRYPTION_KEY, your email and file storage settings, andINITIAL_ADMIN_EMAILandINITIAL_ADMIN_TOKENwithENABLE_INITIAL_ADMIN_BOOTSTRAP=true. Make each secret with this command:openssl rand -base64 32Start it.
docker compose up -d docker compose logs -f migrate appPut HTTPS in front.
Use a reverse proxy such as Caddy, Traefik or nginx.
Create the first admin.
Open
/loginand choose Create the first admin. Then setENABLE_INITIAL_ADMIN_BOOTSTRAP=falseand rundocker compose up -dagain.
No file bucket? Start with docker compose --profile minio up -d to run MinIO beside Sastra. Read the Compose guide
Use Neon for managed Postgres
Create a Neon database.
Create a Postgres 18 project near your server. Copy its pooled and direct connection URLs from Connect. Sastra's migrations enable the required
vectorextension.Download the Neon bundle.
For a new installation, run:
mkdir sastra-neon && cd sastra-neon curl -fsSL https://raw.githubusercontent.com/Sastra-Cloud/sastra/main/deploy/compose/docker-compose.neon.yml -o docker-compose.yml curl -fsSL https://raw.githubusercontent.com/Sastra-Cloud/sastra/main/deploy/compose/.env.example -o .envFill in
.env.Uncomment
DATABASE_URLfor the pooled URL andDATABASE_MIGRATION_URLfor the direct URL. Usesslmode=verify-fullin both. LeavePOSTGRES_PASSWORDblank. Fill in the app address, secrets, email, file storage and first-admin settings from the template.Start it and create the first admin.
Put HTTPS in front, then run:
docker compose up -d docker compose logs -f migrate appOpen
/loginand choose Create the first admin. Afterwards setENABLE_INITIAL_ADMIN_BOOTSTRAP=falseand rundocker compose up -dagain.
This bundle runs the app, migrations and scheduler, and connects to Neon for the database. No Neon API key is needed. Read the Neon setup guide
Coolify
Add Sastra as a resource.
Paste the Compose file as a Docker Compose resource. Or build from the Dockerfile with Coolify Postgres or a Neon database. Coolify handles HTTPS and the domain.
Set the address.
Set
BETTER_AUTH_URLto the exact public HTTPS address.Add a scheduled task.
Run this every minute:
curl -fsS -X POST "http://127.0.0.1:3000/api/cron/tick" -H "Authorization: Bearer $CRON_SECRET"Add a health check.
Use
/api/healthas the container health check.
Railway
Deploy the Sastra template.
It creates the app, a Postgres database with pgvector, and a bucket for files in your own Railway account. The Railway guide shows where to find it.
Set the address.
Set
BETTER_AUTH_URLto the address Railway gave you, or your own domain. Then redeploy.Set up email.
Railway blocks outgoing SMTP on the Hobby plan, so set
RESEND_API_KEYandEMAIL_FROM.Create the first admin.
Set
ENABLE_INITIAL_ADMIN_BOOTSTRAP=true,INITIAL_ADMIN_EMAILandINITIAL_ADMIN_TOKEN. Open/loginand create the first admin. Then set the flag back tofalse.Keep the scheduler running.
The template includes a service that calls
/api/cron/tickevery minute.
A small team usually stays under $10 a month on Railway. Read the Railway guide
Every setting is listed in the environment reference.
After it runs
Upgrades, backups and health.
Upgrade
Change SASTRA_TAG in .env to the new release, then pull and start. New migrations run before the app starts.
docker compose pull
docker compose up -dBack up
Back up the database every night, and the file bucket too.
docker compose exec postgres pg_dump -U sastra sastra > backup.sqlCheck health
Three addresses tell you how the app is doing.
/api/health
/api/ready
/api/versionHelp and contributions
Ask in Discussions, report bugs as issues, and read CONTRIBUTING.md before sending a change. Self-hosted installations are supported by the community and the maintainers as time allows. There is no service level. If you would like someone else to run the servers, that is what Sastra Cloud is for.
Because Sastra is AGPL software, an installation that other people use over a network must offer them its source. The app does this for you with the Source link in the sidebar. If you change Sastra, point that link at your own copy.
Rather not run a server?
Sastra Cloud runs the same software for you: servers, email, backups and upgrades, for $24 a month.
14 days free with either plan, then from $24 a month for 5 people. Cancel any time.