@flowfuse/driver-docker 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/docker.js +35 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/docker.js
CHANGED
|
@@ -97,6 +97,40 @@ const createContainer = async (project, domain) => {
|
|
|
97
97
|
contOptions.Env.push('NODE_EXTRA_CA_CERTS=/usr/local/ssl-certs/chain.pem')
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
const containerList = await this._docker.listImages()
|
|
101
|
+
let containerFound = false
|
|
102
|
+
for (const cont of containerList) {
|
|
103
|
+
if (cont.RepoTags.includes(stack.container)) {
|
|
104
|
+
containerFound = true
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!containerFound) {
|
|
110
|
+
this._app.log.info(`Container for stack ${stack.name} not found, pulling ${stack.container}`)
|
|
111
|
+
// https://github.com/apocas/dockerode/issues/703
|
|
112
|
+
try {
|
|
113
|
+
await new Promise((resolve, reject) => {
|
|
114
|
+
this._docker.pull(stack.container, (err, stream) => {
|
|
115
|
+
if (!err) {
|
|
116
|
+
this._docker.modem.followProgress(stream, onFinished)
|
|
117
|
+
function onFinished (err, output) {
|
|
118
|
+
if (!err) {
|
|
119
|
+
resolve(true)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
reject(err)
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
reject(err)
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
} catch (err) {
|
|
130
|
+
this._app.log.debug(`Error pulling image ${stack.container} ${err.message}`)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
100
134
|
const container = await this._docker.createContainer(contOptions)
|
|
101
135
|
return container.start()
|
|
102
136
|
.then(async () => {
|
|
@@ -441,7 +475,7 @@ module.exports = {
|
|
|
441
475
|
const properties = {
|
|
442
476
|
cpu: 10,
|
|
443
477
|
memory: 256,
|
|
444
|
-
container: '
|
|
478
|
+
container: 'flowfuse/node-red',
|
|
445
479
|
...this._app.config.driver.options?.default_stack
|
|
446
480
|
}
|
|
447
481
|
|