Repository navigation
fix(cli): apply extraCACerts on deploy #5037
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| Fix `extraCACerts` in `trigger.config.ts` having no effect on deployed tasks. The CA file is now included in the deployed image and `NODE_EXTRA_CA_CERTS` points at it, so self-signed or corporate certificates are trusted at runtime. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { depot } from "@depot/cli"; | |
| import { x } from "tinyexec"; | ||
| import type { BuildManifest, BuildRuntime } from "@trigger.dev/core/v3/schemas"; | ||
| import { networkInterfaces } from "os"; | ||
| import { join } from "path"; | ||
| import { join, relative, resolve, sep } from "path"; | ||
| import { safeReadJSONFile } from "../utilities/fileSystem.js"; | ||
| import { readFileSync } from "fs"; | ||
|
|
||
|
|
@@ -55,6 +55,23 @@ export interface BuildImageOptions { | |
| deploymentSpinner?: any; // Replace 'any' with the actual type if known | ||
| } | ||
|
|
||
| /** | ||
| * Where the CA file ends up inside the image. The build copies it into /app using the same layout | ||
| * as additionalFiles (path relative to the project root, with leading `..` segments stripped). | ||
| */ | ||
| export function resolveExtraCACertsImagePath(extraCACerts: string | undefined, workingDir: string) { | ||
| if (!extraCACerts) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const relativePath = relative(workingDir, resolve(workingDir, extraCACerts)) | ||
| .split(sep) | ||
| .filter((segment) => segment !== "..") | ||
| .join("/"); | ||
|
|
||
| return `/app/${relativePath}`; | ||
|
Comment on lines
+67
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Parent-directory CA missing on Windows On Windows, Learn moreThe Example: On Windows, a project in Recommended fix: Make the file copier strip parent segments using the platform path separator, and test that its destination agrees with Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
|
|
||
| export async function buildImage(options: BuildImageOptions): Promise<BuildImageResults> { | ||
| const { | ||
| isLocalBuild, | ||
|
|
||
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.
🔴 Bundled deployments omit the CA setting
With
--local-bundleor--from-bundle,extraCACertsnever reaches their image builds. Those paths bypass thisbuildImagecall, so deployed tasks cannot trust the configured CA.Learn more
The deploy command has separate paths for standard builds and builds from bundles. The local-bundle path copies the CA certificate into its output through the new extension, but handleLocalBundleDeploy sends the bundle to a server instead of calling this image build. The from-bundle path calls buildAndFinalizeFromBundle, which calls
buildImagewithoutextraCACerts. Both images retain an emptyNODE_EXTRA_CA_CERTSsetting.Example: A project sets
extraCACerts: "./certs/company.crt"and deploys with--local-bundle. The certificate is copied into/app/certs/company.crt, but Node does not load it and a task connecting to an internal HTTPS service fails certificate verification.Recommended fix: Store the resolved image CA path in the bundle or build metadata and pass it through both bundle image-building paths. Verify the path matches the copied file for local-bundle and from-bundle builds.
Was this helpful? React with 👍 or 👎 to provide feedback.