File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,29 @@ function installRequirements() {
50
50
51
51
this . serverless . cli . log ( `Docker Image: ${ this . options . dockerImage } ` ) ;
52
52
53
+ // Check docker server os type from 'docker version'
54
+ let volPath ;
55
+ options = [
56
+ 'version' , '--format' , '{{with .Server}}{{.Os}}{{end}}'
57
+ ] ;
58
+ const ps = spawnSync ( cmd , options , { 'timeout' : 2000 , 'encoding' : 'utf-8' } ) ;
59
+ if ( ps . error ) {
60
+ if ( ps . error . code === 'ENOENT' ) {
61
+ throw new Error ( 'docker not found! Please install it.' ) ;
62
+ }
63
+ throw new Error ( ps . error ) ;
64
+ }
65
+ if ( ps . status !== 0 ) {
66
+ throw new Error ( ps . stderr ) ;
67
+ } else if ( ps . stdout . trim ( ) === 'windows' ) {
68
+ volPath = this . servicePath . replace ( / \\ / g, '/' ) . replace ( / ^ \/ m n t \/ / , '/' ) ;
69
+ } else {
70
+ volPath = this . servicePath ;
71
+ }
72
+
53
73
options = [
54
74
'run' , '--rm' ,
55
- '-v' , `${ this . servicePath } :/var/task:z` ,
75
+ '-v' , `${ volPath } :/var/task:z` ,
56
76
] ;
57
77
if ( process . platform === 'linux' )
58
78
options . push ( '-u' , `${ process . getuid ( ) } :${ process . getgid ( ) } ` ) ;
You can’t perform that action at this time.
0 commit comments