@flowfuse/driver-docker 2.7.0 → 2.8.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 CHANGED
@@ -1,3 +1,12 @@
1
+ #### 2.8.0: Release
2
+
3
+ - First pass files api for docker (#108) @hardillb
4
+ - Update README.md (#109) @hardillb
5
+
6
+ #### 2.7.1: Release
7
+
8
+ - Fix logPassthrough (#106) @knolleary
9
+
1
10
  #### 2.7.0: Release
2
11
 
3
12
  - Persistent storage - Docker (#103) @hardillb
package/README.md CHANGED
@@ -11,7 +11,7 @@ In the `flowforge.yml` file
11
11
  driver:
12
12
  type: docker
13
13
  options:
14
- socket: /var/run/docker.sock
14
+ socket: /tmp/docker.sock
15
15
  registry: containers.flowforge.com
16
16
  privateCA: /full/path/to/chain.pem
17
17
  logPassthrough: true
package/docker.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const got = require('got')
2
+ const FormData = require('form-data')
2
3
  const Docker = require('dockerode')
3
4
  const path = require('path')
4
5
  const { chownSync, mkdirSync, rmSync } = require('fs')
@@ -86,7 +87,7 @@ const createContainer = async (project, domain) => {
86
87
  contOptions.Env.push(`FORGE_NR_SECRET=${credentialSecret}`)
87
88
  }
88
89
 
89
- if (this._app.driver.options?.logPassthrough) {
90
+ if (this._app.config.driver.options?.logPassthrough) {
90
91
  contOptions.Env.push('FORGE_LOG_PASSTHROUGH=true')
91
92
  }
92
93
 
@@ -170,6 +171,10 @@ const createContainer = async (project, domain) => {
170
171
  })
171
172
  }
172
173
 
174
+ const getStaticFileUrl = async (instance, filePath) => {
175
+ return `http://${instance.id}:2880/flowforge/files/_/${encodeURIComponent(filePath)}`
176
+ }
177
+
173
178
  /**
174
179
  * Docker Container driver
175
180
  *
@@ -547,5 +552,62 @@ module.exports = {
547
552
  }
548
553
 
549
554
  return properties
555
+ },
556
+
557
+ // Static Assets API
558
+ listFiles: async (instance, filePath) => {
559
+ const fileUrl = await getStaticFileUrl(instance, filePath)
560
+ try {
561
+ return got.get(fileUrl).json()
562
+ } catch (err) {
563
+ err.statusCode = err.response.statusCode
564
+ throw err
565
+ }
566
+ },
567
+
568
+ updateFile: async (instance, filePath, update) => {
569
+ const fileUrl = await getStaticFileUrl(instance, filePath)
570
+ try {
571
+ return got.put(fileUrl, {
572
+ json: update
573
+ })
574
+ } catch (err) {
575
+ err.statusCode = err.response.statusCode
576
+ throw err
577
+ }
578
+ },
579
+
580
+ deleteFile: async (instance, filePath) => {
581
+ const fileUrl = await getStaticFileUrl(instance, filePath)
582
+ try {
583
+ return got.delete(fileUrl)
584
+ } catch (err) {
585
+ err.statusCode = err.response.statusCode
586
+ throw err
587
+ }
588
+ },
589
+ createDirectory: async (instance, filePath, directoryName) => {
590
+ const fileUrl = await getStaticFileUrl(instance, filePath)
591
+ try {
592
+ return got.post(fileUrl, {
593
+ json: { path: directoryName }
594
+ })
595
+ } catch (err) {
596
+ err.statusCode = err.response.statusCode
597
+ throw err
598
+ }
599
+ },
600
+ uploadFile: async (instance, filePath, fileBuffer) => {
601
+ const form = new FormData()
602
+ form.append('file', fileBuffer, { filename: filePath })
603
+ const fileUrl = await getStaticFileUrl(instance, filePath)
604
+ try {
605
+ return got.post(fileUrl, {
606
+ body: form
607
+ })
608
+ } catch (err) {
609
+ err.statusCode = err.response.statusCode
610
+ throw err
611
+ }
550
612
  }
551
613
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/driver-docker",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Docker driver for FlowFuse",
5
5
  "main": "docker.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
24
  "dockerode": "^3.3.1",
25
+ "form-data": "^4.0.0",
25
26
  "got": "^11.8.0"
26
27
  },
27
28
  "devDependencies": {