Тип сервиса
Сервис Ruby
Среда выполнения для веб-приложений, API, фоновых задач и собственных приложений на Ruby.
Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.
На этой странице
Технический профиль
Версии, репозиторий исходного кода и Helm-чарт.
Стеки с этим сервисом
Публичные стеки, в которые входит этот сервис.
Сборка из исходного кода и CI/CD
Шаблоны проектов, Git-провайдеры, CI и реестры контейнеров.
Конфигурация сервиса
Связи с другими сервисами.
Сервисы на его основе
Сервисы каталога, которые наследуют этот сервис.
В StackMaster
Как Ruby работает в StackMaster
How the application is started
The container runs Puma with a configuration file the image writes on every start:
puma -C /usr/local/etc/puma.rb- Puma loads the Rack application from
/usr/src/app/config.ru(PUMA_RACKUP), in the directory/usr/src/app(PUMA_DIRECTORY). The repository must have aconfig.ruat its root, or the variable must point to it. - Puma listens on
0.0.0.0:8080. The port is fixed in the generated configuration and is the port of the service's HTTP endpoint. - The image does not include Puma. It must be in the application's
Gemfile. - A
config/puma.rbin the repository is not loaded by this command. Set these variables on the service instead:PUMA_WORKERS,PUMA_THREADS,PUMA_WORKER_TIMEOUT,PUMA_WORKER_BOOT_TIMEOUT,PUMA_PRELOAD_APP,PUMA_PRUNE_BUNDLER,PUMA_QUIET,PUMA_TAG. A change applies with the next deployment of the service. - The generated configuration sets Puma's environment from
PUMA_ENVIRONMENT, and the image's default for it isdevelopment. The service does not setPUMA_ENVIRONMENTorRACK_ENV. An application that depends on them sets them on the service or in its Dockerfile.
Linked services
Links to other services reach the application as environment variables. Nothing in the image reads them: the application reads them itself. Do not hardcode hosts or credentials.
| Link | Variables |
|---|---|
| Database (MariaDB, MySQL or PostgreSQL) | DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION) |
SMTP_HOST, SMTP_PORT | |
| Redis or Valkey | REDIS_HOST, REDIS_PORT, REDIS_PASSWORD |
| OpenTelemetry Collector | OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL (http/protobuf), OTEL_EXPORTER_OTLP_HEADERS (the Collector's ingest token) |
All links are optional. A variable is present only while its link exists and the linked service is enabled. The mail link carries no credentials. The OpenTelemetry variables are the standard SDK settings: an application or agent that uses an OpenTelemetry SDK exports to the Collector without further configuration; set OTEL_SERVICE_NAME to name the application in traces.
Environment
WODBY_HOSTSis a JSON array of the environment's hosts, not a comma-separated string.WODBY_PRIMARY_HOSTandWODBY_PRIMARY_URLare the canonical ones for links generated outside a request.WODBY_APP_SERVICE_NAMEis this service's host name inside the environment. Other services reach the application at that name on port 8080.WODBY_ENV_TYPEtells a development environment from a production-like one.
Build
The code is copied to /usr/src/app, the working directory. The service's own Dockerfile then runs bundle install when a Gemfile exists, and nothing else. A pipeline that passes a Dockerfile from the repository (wodby ci build ruby -f Dockerfile) uses that file instead, and the repository's Dockerfile then owns gem installation.
The service declares no volume of its own: files written inside the container are lost when it is replaced.
In a development workspace
- The checkout is mounted at
/usr/src/appand served as it is on disk. - Workspace setup installs gems with
workspace-ruby prepare: a frozenbundle install, development and test groups included.Gemfile.lockmust be committed; preparation fails without it and never updates it. Run it again after changing dependencies. - Gems are installed under
.wodby-workspace/in the checkout, which is kept out of Git status without touching.gitignore. - The application is started with
bundle exec puma --bind "tcp://$HOST:$PORT", withHOSTandPORTdefaulting to0.0.0.0and8080. The generated Puma configuration and thePUMA_*variables are not used here.RACK_ENVandRAILS_ENVaredevelopment. WORKSPACE_RUBY_COMMANDon the service replaces that start command.- Puma does not watch files: a code change needs a restart of the service.
- A change to variables or linked services still needs a deployment of the environment.
Check the result
curl -s -o /dev/null -w '%{http_code}' localhost:8080from the container shows whether the application answers on the expected port.printenv | grep -E '^(DB|SMTP|REDIS)_' | cut -d= -f1lists the link variables that are present.
Обзор
Технический профиль Ruby
Версии
Репозиторий исходного кода
Публичный Helm-чарт
Стеки
Стеки, в которые входит Ruby
CI/CD
Сборка Ruby из Git-репозитория
Ruby boilerplate
Используйте его как есть или клонируйте в свой Git-аккаунт.
wodby/ruby-boilerplateCI-провайдеры
StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.
Реестры контейнеров
Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.
Переменные окружения из интеграций
Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к Ruby, и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.
Конфигурация
Конфигурация сервиса Ruby
Технические домены
Связи сервиса
Каждая связь — это подключение Ruby к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.
db
Сервисы, которые подходят для этой связи
sendmail
Сервисы, которые подходят для этой связи
redis
Сервисы, которые подходят для этой связи
otel
Сервисы, которые подходят для этой связи
На основе этого сервиса