@@ -19,6 +19,7 @@ import {resolveIncludeLocal, validateIncludeLocal} from "./parser-includes.js";
1919import globby from "globby" ;
2020import terminalLink from "terminal-link" ;
2121import * as crypto from "crypto" ;
22+ import * as path from "path" ;
2223
2324const GCL_SHELL_PROMPT_PLACEHOLDER = "<gclShellPromptPlaceholder>" ;
2425interface JobOptions {
@@ -687,10 +688,23 @@ export class Job {
687688 if ( helperImageName ) {
688689 await this . pullImage ( writeStreams , helperImageName ) ;
689690 }
690- const { stdout : containerId } = await Utils . spawn ( [
691- this . argv . containerExecutable , "create" , "--user=0:0" , `--volume=${ buildVolumeName } :${ this . ciProjectDir } ` , `--volume=${ tmpVolumeName } :${ this . fileVariablesDir } ` , `${ helperImageName } ` ,
692- ...[ "sh" , "-c" , `chown ${ chownOpt } -R ${ this . ciProjectDir } && chmod ${ chmodOpt } -R ${ this . ciProjectDir } && chown ${ chownOpt } -R /tmp/ && chmod ${ chmodOpt } -R /tmp/` ] ,
693- ] , argv . cwd ) ;
691+
692+ const helperContainerArgs = [
693+ this . argv . containerExecutable , "create" , "--user=0:0" ,
694+ `--volume=${ buildVolumeName } :${ this . ciProjectDir } ` ,
695+ `--volume=${ tmpVolumeName } :${ this . fileVariablesDir } ` ,
696+ ] ;
697+
698+ if ( this . argv . caFile ) {
699+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
700+ if ( await fs . pathExists ( caFilePath ) ) {
701+ helperContainerArgs . push ( `--volume=${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro` ) ;
702+ }
703+ }
704+
705+ helperContainerArgs . push ( `${ helperImageName } ` , "sh" , "-c" , `chown ${ chownOpt } -R ${ this . ciProjectDir } && chmod ${ chmodOpt } -R ${ this . ciProjectDir } && chown ${ chownOpt } -R /tmp/ && chmod ${ chmodOpt } -R /tmp/` ) ;
706+
707+ const { stdout : containerId } = await Utils . spawn ( helperContainerArgs , argv . cwd ) ;
694708 this . _containersToClean . push ( containerId ) ;
695709 if ( await fs . pathExists ( fileVariablesDir ) ) {
696710 await Utils . spawn ( [ this . argv . containerExecutable , "cp" , `${ fileVariablesDir } /.` , `${ containerId } :${ fileVariablesDir } ` ] , argv . cwd ) ;
@@ -966,6 +980,17 @@ export class Job {
966980 dockerCmd += `--add-host=${ extraHost } ` ;
967981 }
968982
983+ if ( this . argv . caFile ) {
984+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
985+ if ( await fs . pathExists ( caFilePath ) ) {
986+ dockerCmd += `--volume ${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro ` ;
987+ expanded [ "SSL_CERT_FILE" ] = "/etc/ssl/certs/ca-certificates.crt" ;
988+ expanded [ "SSL_CERT_DIR" ] = "/etc/ssl/certs" ;
989+ } else {
990+ writeStreams . stderr ( chalk `{yellow WARNING: CA file not found: ${ caFilePath } }\n` ) ;
991+ }
992+ }
993+
969994 for ( const [ key , val ] of Object . entries ( expanded ) ) {
970995 // Replacing `'` with `'\''` to correctly handle single quotes(if `val` contains `'`) in shell commands
971996 dockerCmd += ` -e '${ key } =${ val . toString ( ) . replace ( / ' / g, "'\\''" ) } ' \\\n` ;
@@ -1491,6 +1516,15 @@ export class Job {
14911516 dockerCmd += `--add-host=${ extraHost } ` ;
14921517 }
14931518
1519+ if ( this . argv . caFile ) {
1520+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
1521+ if ( await fs . pathExists ( caFilePath ) ) {
1522+ dockerCmd += `--volume ${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro ` ;
1523+ expanded [ "SSL_CERT_FILE" ] = "/etc/ssl/certs/ca-certificates.crt" ;
1524+ expanded [ "SSL_CERT_DIR" ] = "/etc/ssl/certs" ;
1525+ }
1526+ }
1527+
14941528 const serviceAlias = service . alias ;
14951529 const serviceName = service . name ;
14961530 const serviceNameWithoutVersion = serviceName . replace ( / ( .* ) ( : .* ) / , "$1" ) ;
0 commit comments