# Migrate from Render

> Translate render.yaml services, pre-deploy commands, workers, crons and Postgres to Gregale.

A Render web service usually moves to Gregale without code changes: both
build from source or a Dockerfile, set `PORT`, and pass configuration as
environment variables. Gregale does not read `render.yaml`; this page maps
its pieces to Gregale's and walks through a move.

## How Render maps to Gregale

| Render | Gregale |
| --- | --- |
| Web service | App, deployed with `gregale deploy` |
| Instance | Instance: a Firecracker microVM per instance. Idle apps park and wake on the next request. |
| Native runtime build and start commands | Source builds detect Node, Python and Go and infer the start command ([Deploy a web framework](https://gregale.dev/docs/frameworks.md)); pin it with `hosting.start` in `gregale.yaml` |
| Docker runtime | Your `Dockerfile`, as is ([Container compatibility](https://gregale.dev/docs/container-compatibility.md)) |
| Pre-deploy command | A [release command](https://gregale.dev/docs/releases.md#releases-that-change-the-database): `release.command` in `gregale.yaml` or `release:` in a `Procfile` |
| Health check path | `hosting.health` in `gregale.yaml` |
| Private service | A service in the same [project](https://gregale.dev/docs/multi-service.md), called by name |
| Background worker | A background worker service in a [project](https://gregale.dev/docs/multi-service.md): a service without `ports:` runs all the time |
| Cron job | [Crons](https://gregale.dev/docs/crons.md), which call a path on your app on a schedule |
| Environment variables and secret files | [Secrets](https://gregale.dev/docs/secrets.md) (`gregale env set`) and [environment variables](https://gregale.dev/docs/env.md) |
| Render Postgres | [Managed PostgreSQL](https://gregale.dev/docs/postgres.md), bound to the app as `DATABASE_URL` |
| Preview environments | [Preview environments](https://gregale.dev/docs/preview-environments.md) |
| Custom domains | [Custom domains](https://gregale.dev/docs/custom-domains.md) |
| Blueprint (`render.yaml`) | `gregale.yaml`, or a Compose file for several services |

## Translate the service settings

A Render web service like this:

```yaml
# render.yaml
services:
  - type: web
    name: my-api
    runtime: python
    buildCommand: pip install -r requirements.txt
    startCommand: gunicorn app:app
    preDeployCommand: python manage.py migrate
    healthCheckPath: /healthz
```

becomes:

```yaml
# gregale.yaml
hosting:
  start: gunicorn app:app --bind 0.0.0.0:$PORT
  health: /healthz
release:
  command: python manage.py migrate
```

Gregale installs dependencies from the manifest itself (and runs a Node
`build` script when there is one), so there is no separate build command;
custom build steps belong in a `Dockerfile`. Name the bind address and port
in the start command: Gregale sets `PORT` for every app.

Check what Gregale detects, from the repository root:

```bash
gregale deploy --dry-run
```

## Copy the configuration and deploy

Put the service's environment variables in a `KEY=VALUE` file, one per line,
with values exactly as they should arrive (no quotes). Then deploy:

```bash
gregale deploy --name my-api --secrets-file render.env
rm render.env
```

The values are sealed before the first deployment starts. If it fails:

```bash
gregale app health my-api --errors
gregale logs my-api
```

## The database

Gregale has no one-step import from Render Postgres. Either keep using it
for now (apps reach outside hosts on ports 80 and 443 only, so on Pro and
Scale open the port with `gregale app egress-ports add my-api 5432`), or create a
managed database and restore a `pg_dump` into it:

```bash
gregale add postgres --app my-api --region <region>
gregale postgres attach my-api-postgres my-api --access migration --env MIGRATION_DATABASE_URL
```

Restore through [Connect from your laptop](https://gregale.dev/docs/postgres.md#connect-from-your-laptop)
(it needs app tasks on your plan),
and run migrations with `MIGRATION_DATABASE_URL`, the credential that can
change the schema. `DATABASE_URL` goes through a connection pooler in
transaction mode; see [Managed PostgreSQL](https://gregale.dev/docs/postgres.md#connect-an-app).

## Several services

A Blueprint with a web service, private services and background workers
becomes one [project](https://gregale.dev/docs/multi-service.md): describe the services in a Compose
file and deploy it with `gregale deploy`. Services call each other by name,
and a service without `ports:` runs all the time as a worker.

## Switch traffic

Add your domain to the Gregale app and verify it as
[Custom domains](https://gregale.dev/docs/custom-domains.md) describes, then move DNS. Suspend the
Render service once the Gregale app has served traffic for a while.

Source: https://gregale.dev/docs/migrate-from-render
