# Deploy Ruby

Any Rack-compatible Ruby app runs as a container on the Ruby runtime - the machinery behind the [Rails](/platform/frameworks/rails) and [Sinatra](/platform/frameworks/sinatra) guides, available to Hanami, Roda, Grape, and plain Rack apps too. Detection reads your `Gemfile`; the default port is `3000`.

## The contract

- Serve with a production server (Puma is the default answer), bound to `0.0.0.0` on the routed [port](/create/build-settings#port) - `PORT` is set to it.
- Log to stdout/stderr for [runtime logs](/platform/observability#runtime-logs).

```bash
bundle exec puma -b tcp://0.0.0.0:$PORT
```

## Configuration and database

Containers receive [environment variables](/platform/environment-variables#build-time-and-runtime) at runtime - read `ENV` at boot. `DATABASE_URL` from the [Credentials tab](/platform/databases/connect) is understood by ActiveRecord and Sequel natively.

## Scaling

Sync Ruby servers hold a request per thread - set [concurrency](/create/scaling#concurrency) near your total thread count instead of the default 80, and let idle apps [scale to zero](/create/scaling#min-instances).

## Related

- [Ruby on Rails](/platform/frameworks/rails): The full-framework guide.
- [Sinatra](/platform/frameworks/sinatra): The small-framework guide.
- [Connect an app](/platform/databases/connect): DATABASE_URL, TLS, per-environment databases.
