Spin up ephemeral services to test pull requests in isolation
backend
) in the environment based on a specific Github
repo and branch name (say, main
branch)f-feature-new
targeting the main
branch,
backend
is created in the same environment, referred to as “Preview service”, with the
latest commit of the PR branch as source. This new PR-based service is its own service with secrets, and other
configuration copied from the main service.f-feature-new
branch to get merged into main
branch.
Secrets
section as “ML_API_HOST” and “ML_API_SECRET”.
You can update these keys in Secrets section to turn on “Use in preview environments” flag. It means that when a new
“preview service” is created for on PR, the secrets & their are values from the original service are copied over to the
“preview service” as well.
When the preview service comes up for any given PR, it comes up with same secrets “ML_API_HOST” and “ML_API_SECRET_KEY”
set to point at the same “ML API” service. And it retains the dependency as main service.
ops.json
are provisioned exclusively for the service, automatically. And when the service is deleted, those resources
are deleted automatically.
When a new preview service is created specifically for the PR, the same workflow applies. Existing existing ops.json
configuration in the PR branch is read and new cloud resources are provisioned exclusively for the PR branch and the
preview service. The preview service is its own isolated service running the PR branch’s code.
preview_only: You can define preview_only
in the dependencies if needed to spin up certain resources only in
preview services. Or spin up same resources with different configuration, just for preview services. Say you want to
provision a 10GB RDS instance for pull request previews but a 100GB RDS instance during other times.
In addition, resources in ops.json
are configured differently in other ways by LocalOps, for preview services for
speed of boot-up and cost savings. Backups, encryption and monitoring are turned off in cloud resources created for
preview services.
Following services can be defined in ops.json
(as on June 9 2025):
ops.json
is processed exclusively for any given preview service. So any cron configuration defined within the
ops.json
is provisioned exclusively for the preview service.
Checkout cron docs here for more info.
LOPS_PREVIEW=true
in all preview services as in-built environment
variable.LOPS_SVC_HOST
environment variable with the latest public url of the service.