Skip to content

Deploying on Railway ​

One Homelander deployment serves one community: one Railway project with one service and one volume. There are two ways to set it up:

  • One click from the Railway template — recommended. No terminal, no files: you paste the bot token and your phone and press Deploy.
  • Infrastructure as code with the Railway CLI — for the project's own community and for those who want to build from main.

To run on your own server instead, see deploy-docker.md.

Cost ​

Railway's trial gives the first 30 days free. After that the Hobby plan, $5 a month, covers one community with room to spare. The Free plan puts a service to sleep when nobody uses it, and a sleeping service makes no scheduled backups, so it does not suit a live community. These are Railway's prices, not ours: check railway.com/pricing for the current ones.

One click ​

Deploy on Railway

The template runs the newest release image ghcr.io/igorrius/homelander-bot:0.1 with a volume at /data, a *.up.railway.app domain, a health check and generated secrets.

  1. Create the bot as in step 1 below: /newbot in @BotFather, then /setprivacy → your bot → Disable.

  2. Press Deploy on Railway (the button above), sign in to Railway, then Configure the homelander service:

    • TELEGRAM_BOT_TOKEN: the token from @BotFather;
    • BOOTSTRAP_ADMIN_PHONE: your phone, e.g. +380…; it becomes the first admin.

    Leave the other variables as they are: APP_SECRET and TELEGRAM_WEBHOOK_SECRET are generated for you, and PUBLIC_URL follows the service's domain. Press Deploy.

  3. Check that the deployment is Active, and that https://<domain>/healthz answers {"status":"ok"}. The domain is on the service's Deployments tab.

  4. Become the first admin (step 8), turn on backups and configure the community.

Updates. The template turns on Railway's image auto-updates: when a patch release of 0.1 comes out, Railway installs it at night (02:00–06:00 UTC). A new minor release (0.2, …) may need something from you, so it is never installed by itself: read its upgrade notes, then change the image tag in the service's Settings → Source. See upgrading.md.

Your own domain. Service → Settings → Networking → Custom Domain, then set PUBLIC_URL to https://<your domain> and redeploy.

Infrastructure as code ​

The repository is public, so nothing about a particular deployment goes into it:

  • the infrastructure lives in .railway/railway.ts, which is git-ignored — you create it from the template docs/railway.example.ts and keep it on your computer;
  • secrets and personal data are typed into the Railway UI only.

Choose where the service comes from (the source constant in step 3):

  • A release (source = "image", recommended for a new community): Railway runs the published image ghcr.io/igorrius/homelander-bot and installs fixes of the same minor line by itself. You move to a new minor when you choose. See upgrading.md.
  • main (source = "github"): Railway builds every merge to main. It follows development as it happens; this is how the project's own community runs.

What you need ​

  • A Railway account and the CLI (railway login).
  • Node.js, then npm install in the repository root (the Railway SDK that reads .railway/railway.ts).
  • openssl for generating secrets.
  • A phone with Telegram — the number that becomes the first admin.

1. Create the production bot ​

  1. In @BotFather: /newbot, pick a name and a username. Keep the token for step 4. Use a different bot from the one you develop with.
  2. /setprivacy → choose the bot → Disable. Without this the bot sees only commands and replies in groups, not the messages it will later react to. More on the bot's group settings (who may add it, rights per chat, /setjoingroups): Telegram bot setup.
  3. Optional: /setdescription and /setuserpic — residents see them before pressing Start.
  1. In the Railway UI create an empty project. Name it as you like; the name stays in Railway.

  2. In the repository root:

    bash
    railway link

    and pick that project.

3. Apply the infrastructure ​

bash
mkdir -p .railway && cp docs/railway.example.ts .railway/railway.ts

In .railway/railway.ts:

  • set projectName to the project name exactly as in Railway;
  • set source and, for "image", imageTag to the newest release from the Releases page (without the v);
  • leave domain empty for now.

Then:

bash
railway config plan

Read the plan: it should create the service homelander (from the image ghcr.io/igorrius/homelander-bot:<tag>, or from GitHub igorrius/homelander-bot branch main built from the Dockerfile), the volume homelander-data mounted at /data, and the variables listed in .railway/railway.ts. Nothing should be deleted. Then:

bash
railway config apply

The first deployment fails: the secrets are not set yet. That is expected.

4. Set the secrets in the Railway UI ​

Service homelander → Variables. Add:

VariableValue
APP_SECREToutput of openssl rand -hex 32
TELEGRAM_WEBHOOK_SECREToutput of another openssl rand -hex 32 (only A-Z a-z 0-9 _ - are allowed)
TELEGRAM_BOT_TOKENthe token from step 1
BOOTSTRAP_ADMIN_PHONEyour phone, e.g. +380…; used only until the first admin exists

Optional: MCP_REDIRECT_URIS (comma-separated) lists the redirect URIs AI agents may register to connect through MCP. Leave it unset for Claude and local clients; see mcp.md.

Never paste these values into a chat, an issue or a file in the repository. .railway/railway.ts keeps them with preserve(), so later apply runs leave them as they are.

5. Give the service a domain ​

Service → Settings → Networking → Generate Domain (port 8080). Then write it into domain in .railway/railway.ts so later plans keep it:

bash
railway config plan   # should show no changes, or only the domain

PUBLIC_URL follows the domain by itself (https://$). Redeploy the service so it starts with the secrets and the domain.

6. Backups ​

The service backs the database up by itself into /data/backups: daily at 03:00 UTC from the first start. After step 8, open Settings → Backups in the admin panel and press Create encryption key. Keep the private key it shows outside Railway, for example in a password manager. Details and the restore procedure: backups.md.

/data/backups is on the same volume as the database. To keep copies outside Railway, add the BACKUP_S3_* variables of a private S3-compatible bucket (Cloudflare R2, Backblaze B2, AWS S3, …): every encrypted backup is then copied there too. See backups.md → S3 storage. Without a bucket, the bot can send the files to a private Telegram group (backups.md → Telegram). Also turn on Railway's volume backups: volume homelander-data → Backups → a daily schedule (and weekly, if you like). They survive losing the volume's contents.

7. Check that it runs ​

  • https://<domain>/healthz answers {"status":"ok"}.

  • The deploy logs show listening and no telegram setWebhook failed.

  • Telegram sees the webhook — run this yourself, it contains the token:

    bash
    curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"

    url must be https://<domain>/telegram/webhook/… and last_error_message empty.

8. Become the first admin ​

  1. Open the bot, press Start, then Share my phone number (from the phone in BOOTSTRAP_ADMIN_PHONE). The bot answers with a link to the admin panel.
  2. Open https://<domain>/login, enter the phone; the code arrives in the bot.
  3. In the admin panel, open your user card and fill in your name.
  4. Audit log: the IP of your login should be your real address, not a 10.x / 100.64.x one. If it is internal, TRUST_PROXY does not see the client and all rate limits would be shared by everyone — report it before inviting residents.

9. Configure the community ​

  1. Site → Built-in page: community name, welcome text (Ukrainian and English) and the default language. The home page draws a map of the houses by itself.
  2. Houses: one per building or section — name, address, floors, the apartment number range.
  3. Residency statuses: owner and tenant exist; add others if you need them.
  4. Add the bot to the community group or forum and to the admins' journal, as an admin of the system. They appear under Chats as accepted. Create labels (for example "journal"), hang them on the chats, and in Settings → Notifications pick the label that gets new applications. Details and checks: Telegram bot setup. A group the bot was in before this version shows up only after a message in it, or after re-adding the bot.
  5. Pin the registration link from Overview (https://<domain>/register, also as a QR code) in the chat. Review the applications as they come in; approved residents activate themselves in the bot.

Updating ​

  • From the template: patches install by themselves at night. To move to a new minor, read its upgrade notes, take a backup, then change the image tag in the service's Settings → Source, for example :0.1 → :0.2. See upgrading.md.
  • From a release with .railway/railway.ts: Railway installs new patches of your minor line by itself. To move to a new minor, read its upgrade notes, take a backup, change imageTag, then run railway config plan and railway config apply. The steps are in upgrading.md.
  • From main: every merge into main deploys automatically once the GitHub checks pass.

Database migrations run at start-up and only move forward.

Before changing .railway/railway.ts, always run railway config plan. Never remove the volume from the file: Railway would delete it and the data with it. When the template in docs/railway.example.ts changes, carry the change into your local copy by hand.

When something is wrong ​

SymptomCause and fix
Log: configuration: … is requiredA secret from step 4 is missing.
Log: unable to open database fileRAILWAY_RUN_UID=0 is missing; the volume belongs to root.
502 from RailwayThe app listens on another port: do not set HTTP_ADDR, Railway passes PORT.
The bot is silentgetWebhookInfo shows the error. 401 means TELEGRAM_WEBHOOK_SECRET changed after the webhook was set — redeploy.
The bot does not see group messagesPrivacy mode is still on (step 1.2), or the bot was added before it was turned off — remove and add it again.
Login code never arrivesThe user has not activated the bot, or blocked it; the log shows login code not delivered.

Released under the Apache License 2.0.