@flowfuse/driver-docker 2.1.0 → 2.2.1
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 +9 -0
- package/docker.js +36 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
#### 2.2.1: Release
|
|
2
|
+
|
|
3
|
+
- Fix loading private CA certs in Instances (#87) @hardillb
|
|
4
|
+
|
|
5
|
+
#### 2.2.0: Release
|
|
6
|
+
|
|
7
|
+
- Pull missing Stack containers on first use (#85) @hardillb
|
|
8
|
+
- Change default stack container (#84) @hardillb
|
|
9
|
+
|
|
1
10
|
#### 2.1.0: Release
|
|
2
11
|
|
|
3
12
|
- Add log passthrough support (#82) @hardillb
|
package/docker.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
1
|
const got = require('got')
|
|
3
2
|
const Docker = require('dockerode')
|
|
4
3
|
|
|
@@ -90,13 +89,47 @@ const createContainer = async (project, domain) => {
|
|
|
90
89
|
contOptions.Env.push('FORGE_LOG_PASSTHROUGH=true')
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
if (this._app.config.driver.options?.privateCA
|
|
92
|
+
if (this._app.config.driver.options?.privateCA) {
|
|
94
93
|
contOptions.Binds = [
|
|
95
94
|
`${this._app.config.driver.options.privateCA}:/usr/local/ssl-certs/chain.pem`
|
|
96
95
|
]
|
|
97
96
|
contOptions.Env.push('NODE_EXTRA_CA_CERTS=/usr/local/ssl-certs/chain.pem')
|
|
98
97
|
}
|
|
99
98
|
|
|
99
|
+
const containerList = await this._docker.listImages()
|
|
100
|
+
let containerFound = false
|
|
101
|
+
for (const cont of containerList) {
|
|
102
|
+
if (cont.RepoTags.includes(stack.container)) {
|
|
103
|
+
containerFound = true
|
|
104
|
+
break
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!containerFound) {
|
|
109
|
+
this._app.log.info(`Container for stack ${stack.name} not found, pulling ${stack.container}`)
|
|
110
|
+
// https://github.com/apocas/dockerode/issues/703
|
|
111
|
+
try {
|
|
112
|
+
await new Promise((resolve, reject) => {
|
|
113
|
+
this._docker.pull(stack.container, (err, stream) => {
|
|
114
|
+
if (!err) {
|
|
115
|
+
this._docker.modem.followProgress(stream, onFinished)
|
|
116
|
+
function onFinished (err, output) {
|
|
117
|
+
if (!err) {
|
|
118
|
+
resolve(true)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
reject(err)
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
reject(err)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
} catch (err) {
|
|
129
|
+
this._app.log.debug(`Error pulling image ${stack.container} ${err.message}`)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
100
133
|
const container = await this._docker.createContainer(contOptions)
|
|
101
134
|
return container.start()
|
|
102
135
|
.then(async () => {
|
|
@@ -441,7 +474,7 @@ module.exports = {
|
|
|
441
474
|
const properties = {
|
|
442
475
|
cpu: 10,
|
|
443
476
|
memory: 256,
|
|
444
|
-
container: '
|
|
477
|
+
container: 'flowfuse/node-red',
|
|
445
478
|
...this._app.config.driver.options?.default_stack
|
|
446
479
|
}
|
|
447
480
|
|