-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(cli): experimental --local-bundle deploy mode #4331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
myftija
wants to merge
26
commits into
main
Choose a base branch
from
feature/local-bundle-deploy-tri-12120
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,413
−11
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
81c5d4e
feat(core): add deployment_bundle artifact type and fromBundle deploy…
myftija 6610101
feat(cli): add --local-bundle and --from-bundle deploy modes
myftija 645a4a8
feat(webapp): accept deployment_bundle artifacts and thread fromBundl…
myftija 18c44a5
fix(cli): review fixes for the local-bundle paths
myftija d7fb9ba
fix(cli): round-2 review refinements for local-bundle
myftija 978bbba
fix(webapp): allow host.docker.internal on the Vite dev server
myftija 45f2f6f
fix(cli): warn when build-tuning flags are ignored with --local-bundle
myftija c564578
test(cli): unit tests for the bundle archiver
myftija 332549f
fix(cli): review feedback for --from-bundle error handling
myftija 5c373ad
fix(webapp): treat preview environments as cloud installs
myftija 08ce247
fix(cli): stop the bundle archiver dropping the indexer entry points
myftija 1e226e1
feat(deploy): store local-bundle build env vars encrypted on the depl…
myftija 4a0eb68
fix(deploy): drop undefined build env var values before sending
myftija f3594dc
fix(deploy): fail loud when stored build env vars cannot be read
myftija 8abbe05
fix(webapp): tolerate missing LOGIN_ORIGIN in isCloud
myftija bf9b894
fix(deploy): adapt build env vars flow to reused deployments and scop…
myftija 03f3cf0
fix(cli): honor --dry-run with --from-bundle and guard bundle artifac…
myftija c1d03d6
chore: trim inline comments to essential constraints
myftija a21baf0
chore(cli): reword the local-bundle changeset
myftija 9ca53a0
fix(webapp): let build env var decrypt failures fall through to the g…
myftija 140e4b3
feat(webapp): make deployment artifact and build env var limits confi…
myftija 4a1ebb1
refactor(core,cli,webapp): drop the build env vars stored ack
myftija bbeea39
chore(cli): tighten the local-bundle flag descriptions
myftija c16bbcb
refactor(cli): isolate local-bundle and from-bundle from the classic …
myftija 0706c79
fix(cli): review nits for the isolated bundle paths
myftija b334fcd
fix(cli): correct the artifact guard comment and skip-sync notice con…
myftija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| Add an experimental `--local-bundle` deploy flag that runs the install and bundling steps on your machine and uploads only the build output; the image is still built remotely. Useful when your project's install step needs tooling or credentials that only exist locally. |
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
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
98 changes: 98 additions & 0 deletions
98
apps/webapp/app/routes/api.v1.deployments.$deploymentId.build-env-vars.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { type LoaderFunctionArgs, json } from "@remix-run/server-runtime"; | ||
| import { type GetDeploymentBuildEnvVarsResponseBody } from "@trigger.dev/core/v3"; | ||
| import { z } from "zod"; | ||
| import { prisma } from "~/db.server"; | ||
| import { env } from "~/env.server"; | ||
| import { authenticateApiKeyWithScope } from "~/services/apiAuth.server"; | ||
| import { logger } from "~/services/logger.server"; | ||
| import { decryptSecret, EncryptedSecretValueSchema } from "~/services/secrets/secretStore.server"; | ||
| import { FINAL_DEPLOYMENT_STATUSES } from "~/v3/services/failDeployment.server"; | ||
|
|
||
| const ParamsSchema = z.object({ | ||
| deploymentId: z.string(), | ||
| }); | ||
|
|
||
| // Secret material, deliberately separate from the main GET deployment endpoint. | ||
| export async function loader({ request, params }: LoaderFunctionArgs) { | ||
| const parsedParams = ParamsSchema.safeParse(params); | ||
|
|
||
| if (!parsedParams.success) { | ||
| return json({ error: "Invalid params" }, { status: 400 }); | ||
| } | ||
|
|
||
| try { | ||
| const authResult = await authenticateApiKeyWithScope(request, { | ||
| action: "read", | ||
| resource: { type: "deployments" }, | ||
| }); | ||
|
|
||
| if (!authResult.ok) { | ||
| logger.info("Invalid or missing api key", { url: request.url }); | ||
| return json({ error: authResult.error }, { status: authResult.status }); | ||
| } | ||
|
|
||
| const authenticatedEnv = authResult.authentication.environment; | ||
|
|
||
| const { deploymentId } = parsedParams.data; | ||
|
|
||
| const deployment = await prisma.workerDeployment.findFirst({ | ||
| where: { | ||
| friendlyId: deploymentId, | ||
| environmentId: authenticatedEnv.id, | ||
| }, | ||
| select: { | ||
| id: true, | ||
| status: true, | ||
| buildEnvVars: true, | ||
| }, | ||
| }); | ||
|
|
||
| if (!deployment) { | ||
| return json({ error: "Deployment not found" }, { status: 404 }); | ||
| } | ||
|
|
||
| logger.info("Build env vars read", { | ||
| deploymentId, | ||
| environmentId: authenticatedEnv.id, | ||
| projectId: authenticatedEnv.projectId, | ||
| status: deployment.status, | ||
| hasVars: deployment.buildEnvVars !== null, | ||
| }); | ||
|
|
||
| // Never serve secrets for a build that is no longer active, even if a clear is still in flight | ||
| if (FINAL_DEPLOYMENT_STATUSES.includes(deployment.status)) { | ||
| return json({ variables: {} } satisfies GetDeploymentBuildEnvVarsResponseBody, { | ||
| status: 200, | ||
| }); | ||
| } | ||
|
|
||
| if (!deployment.buildEnvVars) { | ||
| return json({ variables: {} } satisfies GetDeploymentBuildEnvVarsResponseBody, { | ||
| status: 200, | ||
| }); | ||
| } | ||
|
|
||
| // Present-but-unreadable must fail loud: an empty record would let the build run without its secrets | ||
| const envelope = EncryptedSecretValueSchema.safeParse(deployment.buildEnvVars); | ||
|
|
||
| if (!envelope.success) { | ||
| logger.error("Stored build env vars are not a valid encrypted envelope", { | ||
| deploymentId, | ||
| environmentId: authenticatedEnv.id, | ||
| }); | ||
| return json( | ||
| { error: "The stored build environment variables could not be read. Retry the deploy." }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
|
|
||
| const decrypted = await decryptSecret(env.ENCRYPTION_KEY, envelope.data); | ||
| const variables = z.record(z.string()).parse(JSON.parse(decrypted)); | ||
|
|
||
| return json({ variables } satisfies GetDeploymentBuildEnvVarsResponseBody, { status: 200 }); | ||
| } catch (error) { | ||
| if (error instanceof Response) throw error; | ||
| logger.error("Failed to load deployment build env vars", { error }); | ||
| return json({ error: "Internal Server Error" }, { status: 500 }); | ||
| } | ||
| } |
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
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
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
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
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
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
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
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
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
2 changes: 2 additions & 0 deletions
2
...abase/prisma/migrations/20260722155558_add_worker_deployment_build_env_vars/migration.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "public"."WorkerDeployment" ADD COLUMN IF NOT EXISTS "buildEnvVars" JSONB; |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Key-limit default differs from stated design
DEPLOYMENT_BUILD_ENV_VARS_MAX_KEYSdefaults to 400, while the PR description states a 200-key limit. Behavior is otherwise correct; worth confirming the intended default.Was this helpful? React with 👍 or 👎 to provide feedback.