fix(frontend): allow optional Turbo remote cache in web Docker builds#3967
Closed
fix(frontend): allow optional Turbo remote cache in web Docker builds#3967
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds optional Vercel Turbo Remote Cache support to the web Docker builds in
agenta.The recent CI cache work in
agenta_cloudfixed Docker layer caching for image builds. That helped a lot with repeated image builds, but web builds still spent most of their time inside thepnpm turbo run buildstep. The Docker cache can only reuse that layer when the source tree is unchanged. Small frontend changes still invalidate the layer and force Turbo to rebuild the package graph and Next.js apps from scratch.This PR makes the web Dockerfiles able to consume Turbo remote cache credentials when they are provided by CI. When those credentials are not present, the build keeps the existing behavior and uses the local BuildKit cache mounts only.
What changed
Shared helper
web/docker/run-turbo-build.sh/run/secrets/turbo_teamand/run/secrets/turbo_tokenare present and non-emptyTURBO_TEAMandTURBO_TOKENbefore runningpnpm turbo run buildOSS web Dockerfile
web/oss/docker/Dockerfile.ghturbo_teamandturbo_tokenon the Turbo build step.turboand.next/cacheEE web Dockerfile
web/ee/docker/Dockerfile.ghWhy this is safe
The main requirement here is not breaking local builds or environments that do not have Vercel cache credentials.
This implementation keeps that contract:
required=falseFlow with secrets
TURBO_TEAMandTURBO_TOKENinto the Docker build as BuildKit secretsrun-turbo-build.shexports the values and runspnpm turbo run buildFlow without secrets
run-turbo-build.shdetects that the secrets are missingWhy this PR is separate from
agenta_cloudThe
agenta_cloudworkflow checks out this repo and uses the Dockerfiles from here. That meansagenta_cloudcannot activate Turbo remote caching by itself. It also needs these Dockerfiles to understand the BuildKit secrets.This PR is paired with an
agenta_cloudPR that passes the optional secrets into the web image build.Validation
sh -n web/docker/run-turbo-build.shgit diff --checkCompanion PR
agenta_cloud: wiresTURBO_TEAMandTURBO_TOKENinto the web image build as BuildKit secrets