Skip to content

Commit 141b73f

Browse files
committed
Added ensureImage to support Docker integration
1 parent 4376f9a commit 141b73f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class PkgPyFuncs {
3838
this.log('Cleanup is set to "false". Build directory and Docker container (if used) will be retained')
3939
return false
4040
}
41-
this.log("Cleaning build directory")
41+
this.log("Cleaning build directory...")
4242
Fse.removeAsync(this.buildDir)
4343
.catch( err => { this.log(err) } )
4444

4545
if (this.useDocker){
46-
this.log("Removing Docker container")
46+
this.log("Removing Docker container...")
4747
this.runProcess('docker', ['stop',this.containerName,'-t','0'])
4848
}
4949
return true
@@ -118,13 +118,22 @@ class PkgPyFuncs {
118118
}
119119
}
120120

121+
ensureImage(){
122+
const out = this.runProcess('docker', ['images', '--format','{{.Repository}}:{{.Tag}}']).replace(/^\s+|\s+$/g, '')
123+
if ( out != this.dockerImage ){
124+
this.log(`Docker Image ${this.dockerImage} is not already installed on your system. Downloading. This might take a while. Subsequent deploys will be faster...`)
125+
this.runProcess('docker', ['pull', this.dockerImage])
126+
}
127+
}
128+
121129
setupDocker(){
122130
if (!this.useDocker){
123131
return
124132
}
125133
this.log('Packaging using Docker container...')
126134
this.checkDocker()
127-
this.log(`Creating Docker container "${this.containerName}". Might take a while if the Docker Image, "${this.dockerImage}", isn't already downloaded...`)
135+
this.ensureImage()
136+
this.log(`Creating Docker container "${this.containerName}"...`)
128137
this.setupContainer()
129138
this.log('Docker setup completed')
130139
}

0 commit comments

Comments
 (0)