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
  1. 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 .env
  2. Fill in .env.

    Set POSTGRES_PASSWORD, BETTER_AUTH_URL, BETTER_AUTH_SECRET, AUTH_PROVISIONING_SECRET, CRON_SECRET and APP_ENCRYPTION_KEY, your email and file storage settings, and INITIAL_ADMIN_EMAIL and INITIAL_ADMIN_TOKEN with ENABLE_INITIAL_ADMIN_BOOTSTRAP=true. Make each secret with this command:

    openssl rand -base64 32
  3. Start it.

    docker compose up -d
    docker compose logs -f migrate app
  4. Put HTTPS in front.

    Use a reverse proxy such as Caddy, Traefik or nginx.

  5. Create the first admin.

    Open /login and choose Create the first admin. Then set ENABLE_INITIAL_ADMIN_BOOTSTRAP=false and run docker compose up -d again.

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
  1. 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 vector extension.

  2. 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 .env
  3. Fill in .env.

    Uncomment DATABASE_URL for the pooled URL and DATABASE_MIGRATION_URL for the direct URL. Use sslmode=verify-full in both. Leave POSTGRES_PASSWORD blank. Fill in the app address, secrets, email, file storage and first-admin settings from the template.

  4. Start it and create the first admin.

    Put HTTPS in front, then run:

    docker compose up -d
    docker compose logs -f migrate app

    Open /login and choose Create the first admin. Afterwards set ENABLE_INITIAL_ADMIN_BOOTSTRAP=false and run docker compose up -d again.

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

  1. 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.

  2. Set the address.

    Set BETTER_AUTH_URL to the exact public HTTPS address.

  3. 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"
  4. Add a health check.

    Use /api/health as the container health check.

Read the Coolify guide

Railway

  1. 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.

  2. Set the address.

    Set BETTER_AUTH_URL to the address Railway gave you, or your own domain. Then redeploy.

  3. Set up email.

    Railway blocks outgoing SMTP on the Hobby plan, so set RESEND_API_KEY and EMAIL_FROM.

  4. Create the first admin.

    Set ENABLE_INITIAL_ADMIN_BOOTSTRAP=true, INITIAL_ADMIN_EMAIL and INITIAL_ADMIN_TOKEN. Open /login and create the first admin. Then set the flag back to false.

  5. Keep the scheduler running.

    The template includes a service that calls /api/cron/tick every 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 -d

Back up

Back up the database every night, and the file bucket too.

docker compose exec postgres pg_dump -U sastra sastra > backup.sql

Check health

Three addresses tell you how the app is doing.

/api/health
/api/ready
/api/version

Help 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.

Sastra Cloud Your workspace In Singapore or Frankfurt, as you choose Running Its own database and file storage Its own email address Restore points for 7 days Encrypted in transit and at rest Upgrades to each new version