# Moving from Railway

Follow the [six steps](./); this page covers what's specific to Railway.

## Draft the config

Railway's config file describes one service, so run `init` from that service's directory:

```bash
keel init --from railway.json        # or railway.toml
```

What Keel reads from it:
- **The start command, `healthcheckPath` and `numReplicas`** become a `web` service.
- **`preDeployCommand`** becomes `release.command`. A list of commands runs in order, as one command.
- **`cronSchedule`** makes the service a scheduled task instead, with the schedule converted. Railway uses five-field Unix cron and AWS uses a six-field form with days of the week numbered from Sunday = 1. The draft shows the converted expression.
- **A Dockerfile path** is kept. If the file asks for Nixpacks or Railpack, Keel builds with a Dockerfile when the repository has one, and with Cloud Native Buildpacks when it doesn't; `init` prints which.
- **A Procfile beside it** adds the other process types as worker services.

Some things are reported rather than translated:
- **The port.** Railway assigns `PORT` when the app starts, and its file never names one. The draft writes `8080` as a placeholder; change it to the port the app listens on.
- **`sleepApplication`.** An ECS service doesn't sleep when traffic stops.
- **`environments` overrides.** Declare those under `environments:` in `keel.yml`.
- **`buildCommand`.** Put it in the Dockerfile.

## Variables and the database

Railway keeps variables and databases in its dashboard, not in `railway.json`, so the draft has neither. Add them yourself:

1. List the service's variable names in the Railway dashboard or with `railway variables`. Add each one under `secrets:` in `keel.yml`, then set its value:

   ```bash
   keel config set STRIPE_KEY=...
   ```

   Leave out the ones Railway generates from a database reference (`DATABASE_URL` and similar). Keel provides the database's own credentials, as `DATABASE_HOST`, `DATABASE_USER`, `DATABASE_PASSWORD` and the rest.

2. Declare the database:

   ```yaml
   database:
     engine: postgres
     version: "16"
   ```

3. After `keel up`, take a dump through the database's public connection URL from the Railway dashboard, and load it:

   ```bash
   pg_dump -Fc --no-owner --no-acl "$RAILWAY_DATABASE_PUBLIC_URL" > app.dump
   keel db import app.dump
   ```

## Several services

A Railway project with an API, a worker and a cron job has a config file per service. Run `keel init --from` on the main one, then copy the others' commands into `services:` in the same `keel.yml`. One Keel app is one project.
