Skip to content

Commit 89fd1cb

Browse files
author
Jorge Martinez
committed
Fix requirements paths in container when using docker. Closes issue #21
1 parent a520568 commit 89fd1cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

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

3637
clean(){
@@ -74,12 +75,13 @@ class PkgPyFuncs {
7475
}
7576

7677
let cmd = 'pip'
77-
let args = ['install','--upgrade','-t', buildPath, '-r', requirementsPath]
7878
if ( this.useDocker === true ){
7979
cmd = 'docker'
8080
args = ['exec',this.containerName, 'pip', ...args]
81+
requirementsPath = `${this.dockerServicePath}/${requirementsPath}`
8182
}
8283

84+
args = [...args, requirementsPath]
8385
return this.runProcess(cmd,args)
8486
}
8587

@@ -111,7 +113,7 @@ class PkgPyFuncs {
111113
} else {
112114
this.runProcess(
113115
'docker',
114-
['run', '--rm', '-dt', '-v', `${process.cwd()}:/var/task`,
116+
['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`,
115117
'--name',this.containerName, this.dockerImage, 'bash']
116118
)
117119
this.log('Container created')

0 commit comments

Comments
 (0)