Skip to content

PoC: embed Viceroy directly into the fastly binary#1805

Draft
jedisct1 wants to merge 1 commit into
mainfrom
fdenis/viceroy-embedded
Draft

PoC: embed Viceroy directly into the fastly binary#1805
jedisct1 wants to merge 1 commit into
mainfrom
fdenis/viceroy-embedded

Conversation

@jedisct1

@jedisct1 jedisct1 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Change summary

This allows shipping Viceroy inside the fastly binary so the common path becomes pure local extraction. No more downloads.

The embedded binary lives behind a viceroy_embed build tag. Without the tag, fastly builds and behaves exactly as before.

On first run the binary is decompressed. It's embedded as zstd-compressed to avoid bloating the binary too much if Viceroy is not used — each per-platform release archive grows by 8-10 MB. We already require klauspost/compress so no new dependencies are required.

Extraction failures or version mismatches fall through to the existing download flow untouched, as do --viceroy-path and FASTLY_VICEROY_USE_PATH.

The pinned Viceroy version is the contents of pkg/embedded/viceroy/VICEROY_VERSION, currently 0.18.0. Bumping it is a one-line edit followed by a checksums refresh.

make build-embedded builds a CLI executable with Viceroy embedded.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

End users get a self-contained fastly binary (when built with viceroy_embed) that runs fastly compute serve offline, with no network round-trip to fetch Viceroy on first use. Default builds are unaffected.

Are there any considerations that need to be addressed for release?

Per-platform release archives grow by 8-10 MB when built with the viceroy_embed tag.

No breaking changes; the download path remains the fallback and existing overrides (--viceroy-path, FASTLY_VICEROY_USE_PATH) continue to work.

This allows shipping Viceroy inside the fastly binary so the common
path becomes pure local extraction. No more downloads.

The embedded binary lives behind a `viceroy_embed` build tag.

Without the tag, fastly builds and behaves exactly as before.

On first run the binary is decompressed. It's embedded as
ztd-compressed to avoid bloating the binary too much if
viceroy is not used - Each per-platform release archive grows by
8-10 MB. We already require klauspost/compress so no new
dependencies are required.

Extraction failures or version mismatches fall through to the
existing download flow untouched, as do --viceroy-path and
FASTLY_VICEROY_USE_PATH.

The pinned Viceroy version is the contents of
pkg/embedded/viceroy/VICEROY_VERSION, currently 0.18.0.

Bumping it is a one-line edit followed by a checksums refresh.

"make build-embedded" builds a CLI executable with Viceroy embedded.
kpfleming pushed a commit that referenced this pull request Jul 7, 2026
)

### Change summary

The container images (`Dockerfile-go`, `Dockerfile-node`,
`Dockerfile-rust`) re-download Viceroy on each container start (raised
in
#1828 (review)),
this PR adds an explicit `fastly compute install-viceroy` command that
downloads and
installs the Viceroy local-testing binary.



#### Implementation

Rather than duplicate the download logic, the existing installer was
extracted out into a shared `viceroyInstaller`
(`pkg/commands/compute/viceroy.go`).

Both `compute serve` and the new command call it, so every
version/override
mechanism (the manifest's `[local_server] viceroy_version`,
`FASTLY_VICEROY_USE_PATH`)
applies identically during a pre-install. `ServeCommand.GetViceroy` is
now a thin
wrapper, so behavior is unchanged.

This is intentionally simpler than #1805 (which embeds binaries into the
CLI binary).


All Submissions:

* [x] Have you followed the guidelines in our Contributing document?
* [x] Have you checked to ensure there aren't other open [Pull
Requests](https://github.com/fastly/cli/pulls) for the same
update/change?

### New Feature Submissions:

* [x] Does your submission pass tests?

### Changes to Core Features:

* [x] Have you written new tests for your core changes, as applicable?
* [x] Have you successfully run tests with your changes locally?

### User Impact

A new `fastly compute install-viceroy` command lets users (and the
container
images) pre-install Viceroy ahead of time, so `compute serve` can start
without
needing to download it. No change to existing behavior - `compute serve`
still
installs Viceroy on demand if it isn't already present.

### Are there any considerations that need to be addressed for release?

None. No breaking changes - the command is purely additive and the
shared
extraction keeps `compute serve`'s install path identical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant