@flowfuse/driver-docker 2.0.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 +9 -0
- package/README.md +3 -1
- package/docker.js +40 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -14,11 +14,13 @@ driver:
|
|
|
14
14
|
socket: /var/run/docker.sock
|
|
15
15
|
registry: containers.flowforge.com
|
|
16
16
|
privateCA: /full/path/to/chain.pem
|
|
17
|
+
logPassthrough: true
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
- `registry` is the Docker Registry to load Stack Containers from (default: Docker Hub)
|
|
20
21
|
- `socket` is the path to the docker unix domain socket (default: /var/run/docker.sock)
|
|
21
|
-
- privateCA
|
|
22
|
+
- `privateCA`: is the fully qualified path to a pem file containing trusted CA cert chain (default: not set)
|
|
23
|
+
- `logPassthrough` Have Node-RED logs printed in JSON format to container stdout (default: false)
|
|
22
24
|
|
|
23
25
|
### Configuration via environment variables
|
|
24
26
|
|
package/docker.js
CHANGED
|
@@ -86,13 +86,51 @@ const createContainer = async (project, domain) => {
|
|
|
86
86
|
contOptions.Env.push(`FORGE_NR_SECRET=${credentialSecret}`)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
if (this.
|
|
89
|
+
if (this._options?.logPassthrough) {
|
|
90
|
+
contOptions.Env.push('FORGE_LOG_PASSTHROUGH=true')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this._app.config.driver.options?.privateCA && fs.existsSync(this._app.config.driver.options?.privateCA)) {
|
|
90
94
|
contOptions.Binds = [
|
|
91
95
|
`${this._app.config.driver.options.privateCA}:/usr/local/ssl-certs/chain.pem`
|
|
92
96
|
]
|
|
93
97
|
contOptions.Env.push('NODE_EXTRA_CA_CERTS=/usr/local/ssl-certs/chain.pem')
|
|
94
98
|
}
|
|
95
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
|
+
|
|
96
134
|
const container = await this._docker.createContainer(contOptions)
|
|
97
135
|
return container.start()
|
|
98
136
|
.then(async () => {
|
|
@@ -437,7 +475,7 @@ module.exports = {
|
|
|
437
475
|
const properties = {
|
|
438
476
|
cpu: 10,
|
|
439
477
|
memory: 256,
|
|
440
|
-
container: '
|
|
478
|
+
container: 'flowfuse/node-red',
|
|
441
479
|
...this._app.config.driver.options?.default_stack
|
|
442
480
|
}
|
|
443
481
|
|