@@ -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 {
@@ -694,10 +695,23 @@ If you know what you're doing and would like to suppress this warning, use one o
694695 if ( helperImageName ) {
695696 await this . pullImage ( writeStreams , helperImageName ) ;
696697 }
697- const { stdout : containerId } = await Utils . spawn ( [
698- this . argv . containerExecutable , "create" , "--user=0:0" , `--volume=${ buildVolumeName } :${ this . ciProjectDir } ` , `--volume=${ tmpVolumeName } :${ this . fileVariablesDir } ` , `${ helperImageName } ` ,
699- ...[ "sh" , "-c" , `chown ${ chownOpt } -R ${ this . ciProjectDir } && chmod ${ chmodOpt } -R ${ this . ciProjectDir } && chown ${ chownOpt } -R /tmp/ && chmod ${ chmodOpt } -R /tmp/` ] ,
700- ] , argv . cwd ) ;
698+
699+ const helperContainerArgs = [
700+ this . argv . containerExecutable , "create" , "--user=0:0" ,
701+ `--volume=${ buildVolumeName } :${ this . ciProjectDir } ` ,
702+ `--volume=${ tmpVolumeName } :${ this . fileVariablesDir } ` ,
703+ ] ;
704+
705+ if ( this . argv . caFile ) {
706+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
707+ if ( await fs . pathExists ( caFilePath ) ) {
708+ helperContainerArgs . push ( `--volume=${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro` ) ;
709+ }
710+ }
711+
712+ helperContainerArgs . push ( `${ helperImageName } ` , "sh" , "-c" , `chown ${ chownOpt } -R ${ this . ciProjectDir } && chmod ${ chmodOpt } -R ${ this . ciProjectDir } && chown ${ chownOpt } -R /tmp/ && chmod ${ chmodOpt } -R /tmp/` ) ;
713+
714+ const { stdout : containerId } = await Utils . spawn ( helperContainerArgs , argv . cwd ) ;
701715 this . _containersToClean . push ( containerId ) ;
702716 if ( await fs . pathExists ( fileVariablesDir ) ) {
703717 await Utils . spawn ( [ this . argv . containerExecutable , "cp" , `${ fileVariablesDir } /.` , `${ containerId } :${ fileVariablesDir } ` ] , argv . cwd ) ;
@@ -973,6 +987,17 @@ If you know what you're doing and would like to suppress this warning, use one o
973987 dockerCmd += `--add-host=${ extraHost } ` ;
974988 }
975989
990+ if ( this . argv . caFile ) {
991+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
992+ if ( await fs . pathExists ( caFilePath ) ) {
993+ dockerCmd += `--volume ${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro ` ;
994+ expanded [ "SSL_CERT_FILE" ] = "/etc/ssl/certs/ca-certificates.crt" ;
995+ expanded [ "SSL_CERT_DIR" ] = "/etc/ssl/certs" ;
996+ } else {
997+ writeStreams . stderr ( chalk `{yellow WARNING: CA file not found: ${ caFilePath } }\n` ) ;
998+ }
999+ }
1000+
9761001 for ( const [ key , val ] of Object . entries ( expanded ) ) {
9771002 // Replacing `'` with `'\''` to correctly handle single quotes(if `val` contains `'`) in shell commands
9781003 dockerCmd += ` -e '${ key } =${ val . toString ( ) . replace ( / ' / g, "'\\''" ) } ' \\\n` ;
@@ -1498,6 +1523,15 @@ If you know what you're doing and would like to suppress this warning, use one o
14981523 dockerCmd += `--add-host=${ extraHost } ` ;
14991524 }
15001525
1526+ if ( this . argv . caFile ) {
1527+ const caFilePath = path . isAbsolute ( this . argv . caFile ) ? this . argv . caFile : path . resolve ( this . argv . cwd , this . argv . caFile ) ;
1528+ if ( await fs . pathExists ( caFilePath ) ) {
1529+ dockerCmd += `--volume ${ caFilePath } :/etc/ssl/certs/ca-certificates.crt:ro ` ;
1530+ expanded [ "SSL_CERT_FILE" ] = "/etc/ssl/certs/ca-certificates.crt" ;
1531+ expanded [ "SSL_CERT_DIR" ] = "/etc/ssl/certs" ;
1532+ }
1533+ }
1534+
15011535 const serviceAlias = service . alias ;
15021536 const serviceName = service . name ;
15031537 const serviceNameWithoutVersion = serviceName . replace ( / ( .* ) ( : .* ) / , "$1" ) ;
0 commit comments