From e26101e5e362c6ee85e2304dc9110b2183873a4b Mon Sep 17 00:00:00 2001 From: shunt Date: Tue, 25 Aug 2020 16:53:05 -0700 Subject: [PATCH 1/2] Update index.js --- index.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 8a309b0..3ec2db1 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,7 @@ class PkgPyFuncs { if ( !config ) { this.error("No serverless-package-python-functions configuration detected. Please see documentation") } + this.requirementsFile = config.requirementsFile || 'requirements.txt' config.buildDir ? this.buildDir = config.buildDir : this.error("No buildDir configuration specified") this.globalRequirements = config.globalRequirements || [] @@ -34,6 +35,7 @@ class PkgPyFuncs { this.containerName = config.containerName || 'serverless-package-python-functions' this.mountSSH = config.mountSSH || false this.abortOnPackagingErrors = config.abortOnPackagingErrors || false + this.dockerServicePath = '/var/task' } @@ -67,8 +69,6 @@ class PkgPyFuncs { }); const info = _.map(functions, (target) => { - - return { name: target.name, includes: target.package.include, @@ -162,17 +162,19 @@ class PkgPyFuncs { if ( out === this.containerName ){ this.log('Container already exists. Reusing.') - } else { - let args = ['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`] - - if (this.mountSSH) { - args = args.concat(['-v', `${process.env.HOME}/.ssh:/root/.ssh`]) - } + let out = this.runProcess('docker', ['kill', `${this.containerName}`]) + this.log(out) + } + + let args = ['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`] - args = args.concat(['--name',this.containerName, this.dockerImage, 'bash']) - this.runProcess('docker', args) - this.log('Container created') + if (this.mountSSH) { + args = args.concat(['-v', `${process.env.HOME}/.ssh:/root/.ssh`]) } + + args = args.concat(['--name',this.containerName, this.dockerImage, 'bash']) + this.runProcess('docker', args) + this.log('Container created') } ensureImage(){ @@ -213,7 +215,7 @@ class PkgPyFuncs { if (this.globalRequirements){ requirements = _.concat(requirements, this.globalRequirements) } - _.forEach(requirements, (req) => { this.installRequirements(buildPath,req)}) + _.forEach(requirements, (req) => { this.installRequirements(buildPath,req) }) zipper.sync.zip(buildPath).compress().save(`${buildPath}.zip`) } From ac98159b140c3ad945ab453dd7b9443f5ee836a6 Mon Sep 17 00:00:00 2001 From: shunt Date: Wed, 26 Aug 2020 01:01:14 -0700 Subject: [PATCH 2/2] fix bug with github not failing correctly --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3ec2db1..bb8f87c 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,6 @@ class PkgPyFuncs { if ( !config ) { this.error("No serverless-package-python-functions configuration detected. Please see documentation") } - this.requirementsFile = config.requirementsFile || 'requirements.txt' config.buildDir ? this.buildDir = config.buildDir : this.error("No buildDir configuration specified") this.globalRequirements = config.globalRequirements || [] @@ -35,7 +34,6 @@ class PkgPyFuncs { this.containerName = config.containerName || 'serverless-package-python-functions' this.mountSSH = config.mountSSH || false this.abortOnPackagingErrors = config.abortOnPackagingErrors || false - this.dockerServicePath = '/var/task' } @@ -122,7 +120,8 @@ class PkgPyFuncs { if (this.abortOnPackagingErrors){ const countErrorNewLines = errorText.split('\n').length - if(countErrorNewLines < 2 && errorText.toLowerCase().includes('git clone')){ + + if(!errorText.includes("ERROR:") && countErrorNewLines < 2 && errorText.toLowerCase().includes('git clone')){ // Ignore false positive due to pip git clone printing to stderr } else if(errorText.toLowerCase().includes('warning') && !errorText.toLowerCase().includes('error')){ // Ignore warnings