Compare commits

..

6 Commits

Author SHA1 Message Date
69e0f77830 Avoid multiple commands at the same for a stack 2023-11-26 17:29:53 +08:00
16cdaa8ed5 Enable back socket.io polling 2023-11-26 17:28:53 +08:00
5d33c474ec Downgrade from Node.js 20 to Node.js 18.17.1 2023-11-26 17:28:29 +08:00
7385d216a3 Fix 2023-11-25 22:26:12 +08:00
631bc60cb2 Add support for extra info: URLs (#182)
* Always show Down button

* Add URL and improve ArrayInput handling

* Minor
2023-11-25 22:14:21 +08:00
d23e2d8aa1 Enforce Websocket (#181)
* Always show Down button

* Force WebSocket

* Force WebSocket
2023-11-25 21:21:23 +08:00
9 changed files with 109 additions and 30 deletions

View File

@ -195,7 +195,6 @@ export class DockgeServer {
// Create Socket.io
this.io = new socketIO.Server(this.httpServer, {
cors,
transports: [ "websocket" ],
});
this.io.on("connection", async (socket: Socket) => {

View File

@ -5,8 +5,6 @@ import { LimitQueue } from "./utils/limit-queue";
import { DockgeSocket } from "./util-server";
import {
allowedCommandList, allowedRawKeys,
getComposeTerminalName,
getCryptoRandomInt,
PROGRESS_TERMINAL_ROWS,
TERMINAL_COLS,
TERMINAL_ROWS
@ -207,14 +205,20 @@ export class Terminal {
}
public static exec(server : DockgeServer, socket : DockgeSocket | undefined, terminalName : string, file : string, args : string | string[], cwd : string) : Promise<number> {
const terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;
return new Promise((resolve, reject) => {
// check if terminal exists
if (Terminal.terminalMap.has(terminalName)) {
reject("Another operation is already running, please try again later.");
return;
}
if (socket) {
terminal.join(socket);
}
let terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;
if (socket) {
terminal.join(socket);
}
return new Promise((resolve) => {
terminal.onExit((exitCode : number) => {
resolve(exitCode);
});

View File

@ -1,4 +1,4 @@
FROM node:20-bookworm-slim
FROM node:18.17.1-bookworm-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
@ -24,16 +24,3 @@ RUN apt update && apt install --yes --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& npm install pnpm -g \
&& pnpm install -g tsx
# ensures that /var/run/docker.sock exists
# changes the ownership of /var/run/docker.sock
RUN touch /var/run/docker.sock && chown node:node /var/run/docker.sock
# Full Base Image
# MariaDB, Chromium and fonts
#FROM base-slim AS base
#ENV DOCKGE_ENABLE_EMBEDDED_MARIADB=1
#RUN apt update && \
# apt --yes --no-install-recommends install mariadb-server && \
# rm -rf /var/lib/apt/lists/* && \
# apt --yes autoremove

View File

@ -30,6 +30,10 @@ export default {
displayName: {
type: String,
required: true,
},
objectType: {
type: String,
default: "service",
}
},
data() {
@ -41,8 +45,7 @@ export default {
array() {
// Create the array if not exists, it should be safe.
if (!this.service[this.name]) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.service[this.name] = [];
return [];
}
return this.service[this.name];
},
@ -56,8 +59,24 @@ export default {
return this.service[this.name] !== undefined;
},
/**
* Not a good name, but it is used to get the object.
*/
service() {
return this.$parent.$parent.service;
if (this.objectType === "service") {
// Used in Container.vue
return this.$parent.$parent.service;
} else if (this.objectType === "x-dockge") {
if (!this.$parent.$parent.jsonConfig["x-dockge"]) {
return {};
}
// Used in Compose.vue
return this.$parent.$parent.jsonConfig["x-dockge"];
} else {
return {};
}
},
valid() {
@ -81,6 +100,19 @@ export default {
},
methods: {
addField() {
// Create the object if not exists.
if (this.objectType === "x-dockge") {
if (!this.$parent.$parent.jsonConfig["x-dockge"]) {
this.$parent.$parent.jsonConfig["x-dockge"] = {};
}
}
// Create the array if not exists.
if (!this.service[this.name]) {
this.service[this.name] = [];
}
this.array.push("");
},
remove(index) {

View File

@ -49,8 +49,7 @@ export default {
array() {
// Create the array if not exists, it should be safe.
if (!this.service[this.name]) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.service[this.name] = [];
return [];
}
return this.service[this.name];
},
@ -89,6 +88,10 @@ export default {
},
methods: {
addField() {
// Create the array if not exists.
if (!this.service[this.name]) {
this.service[this.name] = [];
}
this.array.push("");
},
remove(index) {

View File

@ -96,5 +96,7 @@
"reverseProxyMsg2": "Check how to config it for WebSocket",
"Cannot connect to the socket server.": "Cannot connect to the socket server.",
"reconnecting...": "Reconnecting...",
"connecting...": "Connecting to the socket server..."
"connecting...": "Connecting to the socket server...",
"url": "URL | URLs",
"extra": "Extra"
}

View File

@ -109,7 +109,7 @@ export default defineComponent({
}, 1500);
socket = io(url, {
transports: [ "websocket" ]
transports: [ "websocket", "polling" ]
});
socket.on("connect", () => {

View File

@ -56,6 +56,13 @@
</button>
</div>
<!-- URLs -->
<div v-if="urls.length > 0" class="mb-3">
<a v-for="(url, index) in urls" :key="index" target="_blank" :href="url.url">
<span class="badge bg-secondary me-2">{{ url.display }}</span>
</a>
</div>
<!-- Progress Terminal -->
<transition name="slide-fade" appear>
<Terminal
@ -111,6 +118,20 @@
<button v-if="false && isEditMode && jsonConfig.services && Object.keys(jsonConfig.services).length > 0" class="btn btn-normal mb-3" @click="addContainer">{{ $t("addContainer") }}</button>
<!-- General -->
<div v-if="isEditMode">
<h4 class="mb-3">{{ $t("extra") }}</h4>
<div class="shadow-box big-padding mb-3">
<!-- URLs -->
<div class="mb-4">
<label class="form-label">
{{ $tc("url", 2) }}
</label>
<ArrayInput name="urls" :display-name="$t('url')" placeholder="https://" object-type="x-dockge" />
</div>
</div>
</div>
<!-- Combined Terminal Output -->
<div v-show="!isEditMode">
<h4 class="mb-3">Terminal</h4>
@ -252,6 +273,34 @@ export default {
};
},
computed: {
urls() {
if (!this.jsonConfig["x-dockge"] || !this.jsonConfig["x-dockge"].urls || !Array.isArray(this.jsonConfig["x-dockge"].urls)) {
return [];
}
let urls = [];
for (const url of this.jsonConfig["x-dockge"].urls) {
let display;
try {
let obj = new URL(url);
let pathname = obj.pathname;
if (pathname === "/") {
pathname = "";
}
display = obj.host + pathname + obj.search;
} catch (e) {
display = url;
}
urls.push({
display,
url,
});
}
return urls;
},
isAdd() {
return this.$route.path === "/compose" && !this.submitted;
},

View File

@ -2,6 +2,9 @@
"name": "dockge",
"version": "1.1.1",
"type": "module",
"engines": {
"node": ">= 18.0.0 && <= 18.17.1"
},
"scripts": {
"fmt": "eslint \"**/*.{ts,vue}\" --fix",
"lint": "eslint \"**/*.{ts,vue}\"",