Skip to content

[Feature Request] Detect Fly.io in builtin platform detection #1142

Closed

Description

@timche

Description

Detect Fly.io in the builtin platform detection (@varlock/ci-env-info), so VARLOCK_PLATFORM is set on Fly Machines and VARLOCK_ENV does not fall back to development there.

Motivation

Fly.io is a common host for long-running apps, and varlock run -- <app> is the documented way to run one there. Today nothing detects it (there is no Fly entry in packages/ci-env-info/src/platforms.ts), so on a Fly Machine VARLOCK_ENV takes the local fallback and resolves to development. A schema using @currentEnv=$VARLOCK_ENV, or deriving its own flag from it as the builtin variables docs suggest, then loads development config in production unless the flag is set explicitly in the image or fly.toml. Nothing warns about it.

Proposed Solution

Add a platform entry for Fly, next to Railway and Render:

  • detect: FLY_APP_NAME together with FLY_MACHINE_ID (both set on every Machine, see runtime environment).
  • name: Fly.io, so VARLOCK_PLATFORM reports it; not a CI platform, so VARLOCK_IS_CI stays false.
  • VARLOCK_ENV: Fly has no environment concept of its own, so either map a detected Machine to production, or leave it unset and have varlock warn when a known hosting platform is detected with no environment mapping, instead of silently using development.
  • Other fields where Fly provides them, e.g. FLY_IMAGE_REF for a build or deploy identifier.

Alternatives

  • Set the environment flag explicitly in the Dockerfile or fly.toml (what we do now). It works, but the silent development fallback is easy to miss.
  • A general warning when VARLOCK_ENV falls back to development inside a container with no platform detected.

Additional Information

Found while deploying a Bun app to Fly under varlock run with a flag derived from $VARLOCK_ENV.

Activity

  1. pullfrog commented on Sep 28, 2026

    @pullfrog
    Contributor
  2. timche commented on Sep 28, 2026

    @timche
    ContributorAuthor

    Detection itself is small: a platform entry matching FLY_APP_NAME together with FLY_MACHINE_ID, reporting Fly.io with ci: false. Fly doesn't expose git metadata or a deploy-level ID, so there are no other fields to extract. I have it ready with a test and a docs line, but on its own it only sets VARLOCK_PLATFORM, and VARLOCK_ENV still falls back to development. So the useful part is the VARLOCK_ENV behaviour:

    1. Map a detected Machine to production. It's simple, but it's wrong for a staging app on Fly unless the user overrides it.
    2. Leave it unmapped, and warn when a known hosting platform is detected without an environment mapping.

    Happy to send the PR once you've picked one (or neither). In the meantime, keying off the platform works: APP_ENV=if(eq($VARLOCK_PLATFORM, "Fly.io"), production, $VARLOCK_ENV).

  3. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    ✅ A fix has been merged to main in #1167 and will ship in the next release. GitHub auto-closed this issue on merge, but the change isn't published yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions