Skip to content

Commit 9611fa8

Browse files
committed
Added extraCACerts config to help with self signed/private ca cert chain
1 parent a0984d5 commit 9611fa8

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

packages/cli-v3/src/Containerfile.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ ARG TRIGGER_DEPLOYMENT_ID
4343
ARG TRIGGER_DEPLOYMENT_VERSION
4444
ARG TRIGGER_CONTENT_HASH
4545
ARG TRIGGER_PROJECT_REF
46+
ARG NODE_EXTRA_CA_CERTS
4647

4748
ENV TRIGGER_PROJECT_ID=${TRIGGER_PROJECT_ID} \
4849
TRIGGER_DEPLOYMENT_ID=${TRIGGER_DEPLOYMENT_ID} \
4950
TRIGGER_DEPLOYMENT_VERSION=${TRIGGER_DEPLOYMENT_VERSION} \
5051
TRIGGER_CONTENT_HASH=${TRIGGER_CONTENT_HASH} \
5152
TRIGGER_PROJECT_REF=${TRIGGER_PROJECT_REF} \
53+
NODE_EXTRA_CA_CERTS=${NODE_EXTRA_CA_CERTS} \
5254
NODE_ENV=production
5355

5456
USER node

packages/cli-v3/src/commands/deploy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
304304
pushImage: options.push,
305305
selfHostedRegistry: !!options.registry,
306306
noCache: options.noCache,
307+
extraCACerts: resolvedConfig.config.extraCACerts?.replace(/^\./,"/app") ?? "",
307308
});
308309
}
309310

@@ -330,6 +331,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
330331
loadImage: options.loadImage,
331332
buildPlatform: options.buildPlatform,
332333
noCache: options.noCache,
334+
extraCACerts: resolvedConfig.config.extraCACerts?.replace(/^\./,"/app") ?? "",
333335
},
334336
deploymentSpinner
335337
);
@@ -779,6 +781,7 @@ type BuildAndPushImageOptions = {
779781
loadImage: boolean;
780782
buildPlatform: string;
781783
noCache: boolean;
784+
extraCACerts: string;
782785
};
783786

784787
type BuildAndPushImageResults =
@@ -837,6 +840,8 @@ async function buildAndPushImage(
837840
`TRIGGER_CONTENT_HASH=${options.contentHash}`,
838841
"--build-arg",
839842
`TRIGGER_PROJECT_REF=${options.projectRef}`,
843+
"--build-arg",
844+
`NODE_EXTRA_CA_CERTS=${options.extraCACerts}`,
840845
"-t",
841846
`${options.registryHost}/${options.imageTag}`,
842847
".",
@@ -961,6 +966,8 @@ async function buildAndPushSelfHostedImage(
961966
`TRIGGER_CONTENT_HASH=${options.contentHash}`,
962967
"--build-arg",
963968
`TRIGGER_PROJECT_REF=${options.projectRef}`,
969+
"--build-arg",
970+
`NODE_EXTRA_CA_CERTS=${options.extraCACerts}`,
964971
"-t",
965972
imageRef,
966973
".", // The build context
@@ -1821,6 +1828,10 @@ export async function copyAdditionalFiles(
18211828
tempDir: string
18221829
): Promise<AdditionalFilesReturn> {
18231830
const additionalFiles = config.additionalFiles ?? [];
1831+
const extraCACerts = config.extraCACerts ?? '';
1832+
if (extraCACerts) {
1833+
additionalFiles.push(extraCACerts);
1834+
}
18241835
const noMatches: string[] = [];
18251836

18261837
if (additionalFiles.length === 0) {

packages/cli-v3/src/workers/prod/entry-point.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ function gatherProcessEnv() {
14851485
TERM: process.env.TERM,
14861486
NODE_PATH: process.env.NODE_PATH,
14871487
HOME: process.env.HOME,
1488+
NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS,
14881489
};
14891490

14901491
// Filter out undefined values

packages/core/src/v3/schemas/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const Config = z.object({
206206
logLevel: z.string().optional(),
207207
enableConsoleLogging: z.boolean().optional(),
208208
postInstall: z.string().optional(),
209+
extraCACerts: z.string().optional(),
209210
});
210211

211212
export type Config = z.infer<typeof Config>;

packages/core/src/v3/types/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,13 @@ export interface ProjectConfig {
8282
* @example "prisma generate"
8383
*/
8484
postInstall?: string;
85+
86+
/**
87+
* CA Cert file to be added to NODE_EXTRA_CA_CERT environment variable in, useful in use with self signed cert in the trigger.dev environment.
88+
*
89+
* @example "./certs/ca.crt"
90+
* Note: must start with "./" and be relative to the project root.
91+
*
92+
*/
93+
extraCACerts?: string;
8594
}

0 commit comments

Comments
 (0)