@@ -51,14 +51,16 @@ class RustPlugin {
51
51
}
52
52
53
53
runDocker ( funcArgs , cargoPackage , binary , profile ) {
54
- const cargoHome = process . env . CARGO_HOME || path . join ( homedir ( ) , ".cargo" ) ;
55
- const cargoRegistry = path . join ( cargoHome , "registry" ) ;
56
- const cargoDownloads = path . join ( cargoHome , "git" ) ;
54
+ const cargoHome = process . env . CARGO_HOME || path . join ( homedir ( ) , '.cargo' ) ;
55
+ const cargoRegistry = path . join ( cargoHome , 'registry' ) ;
56
+ const cargoDownloads = path . join ( cargoHome , 'git' ) ;
57
+
58
+ const dockerCLI = process . env [ 'SLS_DOCKER_CLI' ] || 'docker' ;
57
59
const defaultArgs = [
58
- " run" ,
59
- " --rm" ,
60
- "-t" ,
61
- "-e" ,
60
+ ' run' ,
61
+ ' --rm' ,
62
+ '-t' ,
63
+ '-e' ,
62
64
`BIN=${ binary } ` ,
63
65
`-v` ,
64
66
`${ this . servicePath } :/code` ,
@@ -67,12 +69,12 @@ class RustPlugin {
67
69
`-v` ,
68
70
`${ cargoDownloads } :/root/.cargo/git`
69
71
] ;
70
- const customArgs = [ ] ;
72
+ const customArgs = ( process . env [ 'SLS_DOCKER_ARGS' ] || '' ) . split ( ' ' ) || [ ] ;
71
73
72
74
let cargoFlags = ( funcArgs || { } ) . cargoFlags || this . custom . cargoFlags ;
73
75
if ( profile ) {
74
76
// release or dev
75
- customArgs . push ( "-e" , `PROFILE=${ profile } ` ) ;
77
+ customArgs . push ( '-e' , `PROFILE=${ profile } ` ) ;
76
78
}
77
79
if ( cargoPackage != undefined ) {
78
80
if ( cargoFlags ) {
@@ -83,14 +85,21 @@ class RustPlugin {
83
85
}
84
86
if ( cargoFlags ) {
85
87
// --features awesome-feature, ect
86
- customArgs . push ( "-e" , `CARGO_FLAGS=${ cargoFlags } ` ) ;
88
+ customArgs . push ( '-e' , `CARGO_FLAGS=${ cargoFlags } ` ) ;
87
89
}
88
90
const dockerTag = ( funcArgs || { } ) . dockerTag || this . custom . dockerTag ;
89
- return spawnSync (
90
- "docker" ,
91
- [ ...defaultArgs , ...customArgs , `softprops/lambda-rust:${ dockerTag } ` ] ,
92
- NO_OUTPUT_CAPTURE
91
+
92
+ const finalArgs = [
93
+ ...defaultArgs ,
94
+ ...customArgs ,
95
+ `softprops/lambda-rust:${ dockerTag } `
96
+ ] . filter ( i => i ) ;
97
+
98
+ this . serverless . cli . log (
99
+ `Running container build with: ${ dockerCLI } , args: ${ finalArgs } .`
93
100
) ;
101
+
102
+ return spawnSync ( dockerCLI , finalArgs , NO_OUTPUT_CAPTURE ) ;
94
103
}
95
104
96
105
functions ( ) {
0 commit comments