From a488518f6e2e858a0e7935724514fe3f915807aa Mon Sep 17 00:00:00 2001 From: ThalesC Date: Sat, 18 Nov 2023 02:27:39 -0300 Subject: [PATCH 01/47] Add health status check (#58) * set Health value to Status if existent Check if Health has any value and save it to be displayed. If Health is empty, continue as normal. * add healthy and unhealthy status to be displayed Check if status is either Running or Healthy to set span class to bg-primary, and check if status is Unhealthy to set span class to bg-danger. * Add lint to workflow * Fix lint --------- Co-authored-by: Thales Co-authored-by: Louis Lam --- .github/workflows/ci.yml | 4 +++- backend/stack.ts | 6 +++++- frontend/src/components/Container.vue | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fea3058..2c4525d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,5 +48,7 @@ jobs: - name: Install dependencies run: pnpm install + - name: Lint + run: pnpm run lint # more things can be add later like tests etc.. - + diff --git a/backend/stack.ts b/backend/stack.ts index 1a2366b..94726f0 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -351,7 +351,11 @@ export class Stack { for (let line of lines) { try { let obj = JSON.parse(line); - statusList.set(obj.Service, obj.State); + if (obj.Health === "") { + statusList.set(obj.Service, obj.State); + } else { + statusList.set(obj.Service, obj.Health); + } } catch (e) { } } diff --git a/frontend/src/components/Container.vue b/frontend/src/components/Container.vue index 3eb96ff..9d382be 100644 --- a/frontend/src/components/Container.vue +++ b/frontend/src/components/Container.vue @@ -179,8 +179,10 @@ export default defineComponent({ }, bgStyle() { - if (this.status === "running") { + if (this.status === "running" || this.status === "healthy") { return "bg-primary"; + } else if (this.status === "unhealthy") { + return "bg-danger"; } else { return "bg-secondary"; } From 5ce6b905460b3d99035e4c97a852f853b7e929d6 Mon Sep 17 00:00:00 2001 From: broetchenrackete36 <54035716+broetchenrackete36@users.noreply.github.com> Date: Sat, 18 Nov 2023 06:36:57 +0100 Subject: [PATCH 02/47] Support compose.y[a]ml and docker-compose.y[a]ml (#55) * Support compose.y[a]ml and docker-compose.y[a]ml * using for-loop to iterate over supported compose filenames * Fix lint --------- Co-authored-by: Louis Lam --- backend/stack.ts | 15 +++++++++++++-- frontend/src/pages/Compose.vue | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/stack.ts b/backend/stack.ts index 94726f0..af1b745 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -24,6 +24,7 @@ export class Stack { protected _status: number = UNKNOWN; protected _composeYAML?: string; protected _configFilePath?: string; + protected _composeFileName: string = "compose.yaml"; protected server: DockgeServer; protected combinedTerminal? : Terminal; @@ -34,6 +35,15 @@ export class Stack { this.name = name; this.server = server; this._composeYAML = composeYAML; + + // Check if compose file name is different from compose.yaml + const supportedFileNames = [ "compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml" ]; + for (const filename of supportedFileNames) { + if (fs.existsSync(path.join(this.path, filename))) { + this._composeFileName = filename; + break; + } + } } toJSON() : object { @@ -50,6 +60,7 @@ export class Stack { status: this._status, tags: [], isManagedByDockge: this.isManagedByDockge, + composeFileName: this._composeFileName, }; } @@ -84,7 +95,7 @@ export class Stack { get composeYAML() : string { if (this._composeYAML === undefined) { try { - this._composeYAML = fs.readFileSync(path.join(this.path, "compose.yaml"), "utf-8"); + this._composeYAML = fs.readFileSync(path.join(this.path, this._composeFileName), "utf-8"); } catch (e) { this._composeYAML = ""; } @@ -135,7 +146,7 @@ export class Stack { } // Write or overwrite the compose.yaml - fs.writeFileSync(path.join(dir, "compose.yaml"), this.composeYAML); + fs.writeFileSync(path.join(dir, this._composeFileName), this.composeYAML); } async deploy(socket? : DockgeSocket) : Promise { diff --git a/frontend/src/pages/Compose.vue b/frontend/src/pages/Compose.vue index 4ccb0b6..0709106 100644 --- a/frontend/src/pages/Compose.vue +++ b/frontend/src/pages/Compose.vue @@ -118,7 +118,7 @@
-

compose.yaml

+

{{ stack.composeFileName }}

From 13c3dac44dd0a3c0906c076b1276cf1693df72d4 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 18 Nov 2023 13:59:40 +0800 Subject: [PATCH 03/47] ESLint, update vite to 5.0.0 and other dependencies (#63) * Update vite to 5.0.0 and other dependencies * Eslint * Update workflow --- .eslintrc.cjs | 3 + .github/workflows/ci.yml | 5 +- backend/database.ts | 2 +- backend/dockge-server.ts | 2 +- .../socket-handlers/main-socket-handler.ts | 1 - frontend/src/components/ArraySelect.vue | 2 +- frontend/src/components/Container.vue | 2 +- frontend/src/components/NetworkInput.vue | 2 +- frontend/src/components/Uptime.vue | 1 - frontend/src/components/settings/General.vue | 4 +- frontend/src/vite-env.d.ts | 1 + package.json | 8 +- pnpm-lock.yaml | 497 +++++++++++++++--- 13 files changed, 447 insertions(+), 83 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 1a292dc..0a6dee2 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -92,6 +92,9 @@ module.exports = { "one-var": [ "error", "never" ], "max-statements-per-line": [ "error", { "max": 1 }], "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-unused-vars": [ "warn", { + "args": "none" + }], "prefer-const" : "off", }, }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c4525d..c79e917 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,15 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node: [18.x, 20.x] # Can be changed + node: [20.x] # Can be changed runs-on: ${{ matrix.os }} steps: - name: Checkout Code uses: actions/checkout@v4 + - run: git config --global core.autocrlf false # Mainly for Windows + - uses: actions/checkout@v3 + - name: Setup Node.js uses: actions/setup-node@v3 with: diff --git a/backend/database.ts b/backend/database.ts index d508af4..814e61c 100644 --- a/backend/database.ts +++ b/backend/database.ts @@ -80,7 +80,7 @@ export class Database { * @param {boolean} noLog Should logs not be output? * @returns {Promise} */ - static async connect(autoloadModels = true, noLog = false) { + static async connect(autoloadModels = true) { const acquireConnectionTimeout = 120 * 1000; let dbConfig; try { diff --git a/backend/dockge-server.ts b/backend/dockge-server.ts index ca081b5..ea781ff 100644 --- a/backend/dockge-server.ts +++ b/backend/dockge-server.ts @@ -291,7 +291,7 @@ export class DockgeServer { } // Run every 5 seconds - const job = Cron("*/2 * * * * *", { + Cron("*/2 * * * * *", { protect: true, // Enabled over-run protection. }, () => { log.debug("server", "Cron job running"); diff --git a/backend/socket-handlers/main-socket-handler.ts b/backend/socket-handlers/main-socket-handler.ts index 194d093..1547840 100644 --- a/backend/socket-handlers/main-socket-handler.ts +++ b/backend/socket-handlers/main-socket-handler.ts @@ -1,5 +1,4 @@ import { SocketHandler } from "../socket-handler.js"; -import { Socket } from "socket.io"; import { DockgeServer } from "../dockge-server"; import { log } from "../log"; import { R } from "redbean-node"; diff --git a/frontend/src/components/ArraySelect.vue b/frontend/src/components/ArraySelect.vue index 563bcbd..ebf505c 100644 --- a/frontend/src/components/ArraySelect.vue +++ b/frontend/src/components/ArraySelect.vue @@ -5,7 +5,7 @@
  • diff --git a/frontend/src/components/Container.vue b/frontend/src/components/Container.vue index 9d382be..0826437 100644 --- a/frontend/src/components/Container.vue +++ b/frontend/src/components/Container.vue @@ -9,7 +9,7 @@ diff --git a/frontend/src/components/NetworkInput.vue b/frontend/src/components/NetworkInput.vue index 57f3c3f..84f9fef 100644 --- a/frontend/src/components/NetworkInput.vue +++ b/frontend/src/components/NetworkInput.vue @@ -32,7 +32,7 @@ class="form-control" @keyup.enter="createExternelNetwork" /> -
  • diff --git a/frontend/src/components/Uptime.vue b/frontend/src/components/Uptime.vue index 84c2c27..5d9c6fc 100644 --- a/frontend/src/components/Uptime.vue +++ b/frontend/src/components/Uptime.vue @@ -19,7 +19,6 @@ export default { computed: { uptime() { - return "0.00%"; return this.$t("notAvailableShort"); }, diff --git a/frontend/src/components/settings/General.vue b/frontend/src/components/settings/General.vue index f9cf5c3..b0f3dc2 100644 --- a/frontend/src/components/settings/General.vue +++ b/frontend/src/components/settings/General.vue @@ -68,13 +68,13 @@