Skip to content

Commit 1f3baa1

Browse files
Merge pull request #22 from JFox/fix-docker-requirements
Fix requirements paths in container when using docker. Closes issue #21
2 parents a48c76e + 917d4ce commit 1f3baa1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class PkgPyFuncs {
3232
this.useDocker = config.useDocker || false
3333
this.dockerImage = config.dockerImage || `lambci/lambda:build-${this.serverless.service.provider.runtime}`
3434
this.containerName = config.containerName || 'serverless-package-python-functions'
35+
this.dockerServicePath = '/var/task'
3536
}
3637

3738
clean(){
@@ -75,13 +76,15 @@ class PkgPyFuncs {
7576
}
7677

7778
let cmd = 'pip'
78-
let args = ['install','--upgrade','-t', upath.normalize(buildPath), '-r', upath.normalize(requirementsPath)]
79+
let args = ['install','--upgrade','-t', upath.normalize(buildPath), '-r']
7980
if ( this.useDocker === true ){
8081
cmd = 'docker'
81-
args = ['exec',this.containerName, 'pip', ...args]
82+
args = ['exec', this.containerName, 'pip', ...args]
83+
requirementsPath = `${this.dockerServicePath}/${requirementsPath}`
8284
}
8385

84-
return this.runProcess(cmd,args)
86+
args = [...args, upath.normalize(requirementsPath)]
87+
return this.runProcess(cmd, args)
8588
}
8689

8790
checkDocker(){
@@ -112,7 +115,7 @@ class PkgPyFuncs {
112115
} else {
113116
this.runProcess(
114117
'docker',
115-
['run', '--rm', '-dt', '-v', `${process.cwd()}:/var/task`,
118+
['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`,
116119
'--name',this.containerName, this.dockerImage, 'bash']
117120
)
118121
this.log('Container created')

0 commit comments

Comments
 (0)