@flowfuse/driver-docker 2.16.0 → 2.18.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/.github/workflows/build.yml +1 -1
- package/.github/workflows/release-publish.yml +1 -1
- package/CHANGELOG.md +9 -0
- package/docker.js +41 -0
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
17
17
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
18
|
-
uses: actions/setup-node@
|
|
18
|
+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
19
19
|
with:
|
|
20
20
|
node-version: ${{ matrix.node-version }}
|
|
21
21
|
- name: Install Dependencies
|
|
@@ -9,7 +9,7 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
steps:
|
|
11
11
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
12
|
-
- uses: actions/setup-node@
|
|
12
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
13
13
|
with:
|
|
14
14
|
node-version: 18
|
|
15
15
|
- run: npm ci --omit dev
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
#### 2.18.0: Release
|
|
2
|
+
|
|
3
|
+
- Bump tar-fs from 2.1.2 to 2.1.3 (#133) @app/dependabot
|
|
4
|
+
- Add Resources API endpoint (#132) @hardillb
|
|
5
|
+
|
|
6
|
+
#### 2.17.0: Release
|
|
7
|
+
|
|
8
|
+
- Bump actions/setup-node from 4.3.0 to 4.4.0 (#130)
|
|
9
|
+
|
|
1
10
|
#### 2.16.0: Release
|
|
2
11
|
|
|
3
12
|
- chore: fix lint script (#128) @ppawlowski
|
package/docker.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const got = require('got')
|
|
2
2
|
const FormData = require('form-data')
|
|
3
3
|
const Docker = require('dockerode')
|
|
4
|
+
const { WebSocket } = require('ws')
|
|
4
5
|
|
|
5
6
|
const createContainer = async (project, domain) => {
|
|
6
7
|
const stack = project.ProjectStack.properties
|
|
@@ -765,5 +766,45 @@ module.exports = {
|
|
|
765
766
|
|
|
766
767
|
}
|
|
767
768
|
}
|
|
769
|
+
},
|
|
770
|
+
|
|
771
|
+
// Resources API
|
|
772
|
+
resources: async (project) => {
|
|
773
|
+
if (this._projects[project.id] === undefined) {
|
|
774
|
+
return { state: 'unknown' }
|
|
775
|
+
}
|
|
776
|
+
const result = await got.get('http://' + project.id + ':2880/flowforge/resources').json()
|
|
777
|
+
if (Array.isArray(result)) {
|
|
778
|
+
return {
|
|
779
|
+
meta: {},
|
|
780
|
+
resources: result,
|
|
781
|
+
count: result.length
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
return result
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
resourcesStream: async (project, socket) => {
|
|
788
|
+
if (this._projects[project.id] === undefined) {
|
|
789
|
+
throw new Error('Cannot get instance resources')
|
|
790
|
+
}
|
|
791
|
+
const url = 'ws://' + project.id + ':2800/flowforge/resources'
|
|
792
|
+
const resourceStream = new WebSocket(url, {})
|
|
793
|
+
|
|
794
|
+
resourceStream.on('message', (data) => {
|
|
795
|
+
socket.send(data)
|
|
796
|
+
})
|
|
797
|
+
resourceStream.on('error', (err) => {
|
|
798
|
+
this._app.log.error(`Error in resource stream: ${err}`)
|
|
799
|
+
socket.close()
|
|
800
|
+
})
|
|
801
|
+
socket.on('close', () => {
|
|
802
|
+
try {
|
|
803
|
+
resourceStream.close()
|
|
804
|
+
} catch (_err) {
|
|
805
|
+
// ignore error
|
|
806
|
+
}
|
|
807
|
+
})
|
|
808
|
+
return resourceStream
|
|
768
809
|
}
|
|
769
810
|
}
|