Skip to content

Commit 87e7eb1

Browse files
Merge pull request #47 from noxasaxon/clean-docker-before-use
bugfix: Clean docker container before use to prevent packaging failures
2 parents d3ebe60 + ac98159 commit 87e7eb1

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

index.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ class PkgPyFuncs {
6767
});
6868

6969
const info = _.map(functions, (target) => {
70-
71-
7270
return {
7371
name: target.name,
7472
includes: target.package.include,
@@ -122,7 +120,8 @@ class PkgPyFuncs {
122120
if (this.abortOnPackagingErrors){
123121
const countErrorNewLines = errorText.split('\n').length
124122

125-
if(countErrorNewLines < 2 && errorText.toLowerCase().includes('git clone')){
123+
124+
if(!errorText.includes("ERROR:") && countErrorNewLines < 2 && errorText.toLowerCase().includes('git clone')){
126125
// Ignore false positive due to pip git clone printing to stderr
127126
} else if(errorText.toLowerCase().includes('warning') && !errorText.toLowerCase().includes('error')){
128127
// Ignore warnings
@@ -162,17 +161,19 @@ class PkgPyFuncs {
162161

163162
if ( out === this.containerName ){
164163
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-
}
164+
let out = this.runProcess('docker', ['kill', `${this.containerName}`])
165+
this.log(out)
166+
}
167+
168+
let args = ['run', '--rm', '-dt', '-v', `${process.cwd()}:${this.dockerServicePath}`]
171169

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

178179
ensureImage(){
@@ -213,7 +214,7 @@ class PkgPyFuncs {
213214
if (this.globalRequirements){
214215
requirements = _.concat(requirements, this.globalRequirements)
215216
}
216-
_.forEach(requirements, (req) => { this.installRequirements(buildPath,req)})
217+
_.forEach(requirements, (req) => { this.installRequirements(buildPath,req) })
217218
zipper.sync.zip(buildPath).compress().save(`${buildPath}.zip`)
218219
}
219220

0 commit comments

Comments
 (0)