Skip to content

Commit e26101e

Browse files
committed
Update index.js
1 parent d3ebe60 commit e26101e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PkgPyFuncs {
2424
if ( !config ) {
2525
this.error("No serverless-package-python-functions configuration detected. Please see documentation")
2626
}
27+
2728
this.requirementsFile = config.requirementsFile || 'requirements.txt'
2829
config.buildDir ? this.buildDir = config.buildDir : this.error("No buildDir configuration specified")
2930
this.globalRequirements = config.globalRequirements || []
@@ -34,6 +35,7 @@ class PkgPyFuncs {
3435
this.containerName = config.containerName || 'serverless-package-python-functions'
3536
this.mountSSH = config.mountSSH || false
3637
this.abortOnPackagingErrors = config.abortOnPackagingErrors || false
38+
3739
this.dockerServicePath = '/var/task'
3840
}
3941

@@ -67,8 +69,6 @@ class PkgPyFuncs {
6769
});
6870

6971
const info = _.map(functions, (target) => {
70-
71-
7272
return {
7373
name: target.name,
7474
includes: target.package.include,
@@ -162,17 +162,19 @@ class PkgPyFuncs {
162162

163163
if ( out === this.containerName ){
164164
this.log('Container already exists. Reusing.')
165-
} else {
166-
let args = ['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`]
167-
168-
if (this.mountSSH) {
169-
args = args.concat(['-v', `${process.env.HOME}/.ssh:/root/.ssh`])
170-
}
165+
let out = this.runProcess('docker', ['kill', `${this.containerName}`])
166+
this.log(out)
167+
}
168+
169+
let args = ['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`]
171170

172-
args = args.concat(['--name',this.containerName, this.dockerImage, 'bash'])
173-
this.runProcess('docker', args)
174-
this.log('Container created')
171+
if (this.mountSSH) {
172+
args = args.concat(['-v', `${process.env.HOME}/.ssh:/root/.ssh`])
175173
}
174+
175+
args = args.concat(['--name',this.containerName, this.dockerImage, 'bash'])
176+
this.runProcess('docker', args)
177+
this.log('Container created')
176178
}
177179

178180
ensureImage(){
@@ -213,7 +215,7 @@ class PkgPyFuncs {
213215
if (this.globalRequirements){
214216
requirements = _.concat(requirements, this.globalRequirements)
215217
}
216-
_.forEach(requirements, (req) => { this.installRequirements(buildPath,req)})
218+
_.forEach(requirements, (req) => { this.installRequirements(buildPath,req) })
217219
zipper.sync.zip(buildPath).compress().save(`${buildPath}.zip`)
218220
}
219221

0 commit comments

Comments
 (0)