mirror of
https://github.com/louislam/dockge.git
synced 2025-02-22 19:45:56 +00:00
wip
This commit is contained in:
parent
d7f4873405
commit
21e736459e
15 changed files with 82 additions and 27 deletions
|
@ -11,7 +11,7 @@ export default obj;
|
||||||
|
|
||||||
// How much time in ms to wait between update checks
|
// How much time in ms to wait between update checks
|
||||||
const UPDATE_CHECKER_INTERVAL_MS = 1000 * 60 * 60 * 48;
|
const UPDATE_CHECKER_INTERVAL_MS = 1000 * 60 * 60 * 48;
|
||||||
const CHECK_URL = "https://uptime.kuma.pet/version";
|
const CHECK_URL = "https://dockge.kuma.pet/version";
|
||||||
|
|
||||||
let interval : NodeJS.Timeout;
|
let interval : NodeJS.Timeout;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface DBConfig {
|
||||||
|
|
||||||
export class Database {
|
export class Database {
|
||||||
/**
|
/**
|
||||||
* SQLite file path (Default: ./data/kuma.db)
|
* SQLite file path (Default: ./data/dockge.db)
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
static sqlitePath;
|
static sqlitePath;
|
||||||
|
|
|
@ -69,7 +69,7 @@ export class DockgeServer {
|
||||||
// Catch unexpected errors here
|
// Catch unexpected errors here
|
||||||
let unexpectedErrorHandler = (error : unknown) => {
|
let unexpectedErrorHandler = (error : unknown) => {
|
||||||
console.trace(error);
|
console.trace(error);
|
||||||
console.error("If you keep encountering errors, please report to https://github.com/louislam/uptime-kuma/issues");
|
console.error("If you keep encountering errors, please report to https://github.com/louislam/dockge");
|
||||||
};
|
};
|
||||||
process.addListener("unhandledRejection", unexpectedErrorHandler);
|
process.addListener("unhandledRejection", unexpectedErrorHandler);
|
||||||
process.addListener("uncaughtException", unexpectedErrorHandler);
|
process.addListener("uncaughtException", unexpectedErrorHandler);
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||||
|
|
||||||
let terminal = Terminal.getTerminal(terminalName);
|
let terminal = Terminal.getTerminal(terminalName);
|
||||||
if (terminal instanceof InteractiveTerminal) {
|
if (terminal instanceof InteractiveTerminal) {
|
||||||
log.debug("terminalInput", "Terminal found, writing to terminal.");
|
//log.debug("terminalInput", "Terminal found, writing to terminal.");
|
||||||
terminal.write(cmd);
|
terminal.write(cmd);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Terminal not found or it is not a Interactive Terminal.");
|
throw new Error("Terminal not found or it is not a Interactive Terminal.");
|
||||||
|
@ -79,7 +79,7 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Interactive Terminal for containers
|
// Interactive Terminal for containers
|
||||||
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, callback) => {
|
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, shell : unknown, callback) => {
|
||||||
try {
|
try {
|
||||||
checkLogin(socket);
|
checkLogin(socket);
|
||||||
|
|
||||||
|
@ -91,12 +91,16 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||||
throw new ValidationError("Service name must be a string.");
|
throw new ValidationError("Service name must be a string.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof(shell) !== "string") {
|
||||||
|
throw new ValidationError("Shell must be a string.");
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("interactiveTerminal", "Stack name: " + stackName);
|
log.debug("interactiveTerminal", "Stack name: " + stackName);
|
||||||
log.debug("interactiveTerminal", "Service name: " + serviceName);
|
log.debug("interactiveTerminal", "Service name: " + serviceName);
|
||||||
|
|
||||||
// Get stack
|
// Get stack
|
||||||
const stack = Stack.getStack(server, stackName);
|
const stack = Stack.getStack(server, stackName);
|
||||||
stack.joinContainerTerminal(socket, serviceName);
|
stack.joinContainerTerminal(socket, serviceName, shell);
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|
|
@ -317,14 +317,14 @@ export class Stack {
|
||||||
terminal.start();
|
terminal.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
async joinContainerTerminal(socket: DockgeSocket, serviceName: string, index: number = 0) {
|
async joinContainerTerminal(socket: DockgeSocket, serviceName: string, shell : string = "sh", index: number = 0) {
|
||||||
const terminalName = getContainerExecTerminalName(this.name, serviceName, index);
|
const terminalName = getContainerExecTerminalName(this.name, serviceName, index);
|
||||||
let terminal = Terminal.getTerminal(terminalName);
|
let terminal = Terminal.getTerminal(terminalName);
|
||||||
|
|
||||||
if (!terminal) {
|
if (!terminal) {
|
||||||
terminal = new InteractiveTerminal(this.server, terminalName, "docker", [ "compose", "exec", serviceName, "bash" ], this.path);
|
terminal = new InteractiveTerminal(this.server, terminalName, "docker", [ "compose", "exec", serviceName, shell ], this.path);
|
||||||
terminal.rows = TERMINAL_ROWS;
|
terminal.rows = TERMINAL_ROWS;
|
||||||
log.debug("deployStack", "Terminal created");
|
log.debug("joinContainerTerminal", "Terminal created");
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.join(socket);
|
terminal.join(socket);
|
||||||
|
|
|
@ -98,12 +98,12 @@ export class Terminal {
|
||||||
// Remove room
|
// Remove room
|
||||||
this.server.io.in(this.name).socketsLeave(this.name);
|
this.server.io.in(this.name).socketsLeave(this.name);
|
||||||
|
|
||||||
|
Terminal.terminalMap.delete(this.name);
|
||||||
|
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
|
||||||
|
|
||||||
if (this.callback) {
|
if (this.callback) {
|
||||||
this.callback(res.exitCode);
|
this.callback(res.exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Terminal.terminalMap.delete(this.name);
|
|
||||||
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
############################################
|
||||||
|
# ⭐ Main Image
|
||||||
|
############################################
|
||||||
FROM louislam/dockge:base
|
FROM louislam/dockge:base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --chown=node:node . .
|
COPY --chown=node:node . .
|
||||||
|
@ -7,3 +10,10 @@ VOLUME /app/data
|
||||||
EXPOSE 5001
|
EXPOSE 5001
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
CMD ["tsx", "./backend/index.ts"]
|
CMD ["tsx", "./backend/index.ts"]
|
||||||
|
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Mark as Nightly
|
||||||
|
############################################
|
||||||
|
FROM release AS nightly
|
||||||
|
RUN pnpm run mark-as-nightly
|
||||||
|
|
22
extra/mark-as-nightly.ts
Normal file
22
extra/mark-as-nightly.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import pkg from "../package.json";
|
||||||
|
import fs from "fs";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
const oldVersion = pkg.version;
|
||||||
|
const newVersion = oldVersion + "-nightly-" + dayjs().format("YYYYMMDDHHmmss");
|
||||||
|
|
||||||
|
console.log("Old Version: " + oldVersion);
|
||||||
|
console.log("New Version: " + newVersion);
|
||||||
|
|
||||||
|
if (newVersion) {
|
||||||
|
// Process package.json
|
||||||
|
pkg.version = newVersion;
|
||||||
|
//pkg.scripts.setup = pkg.scripts.setup.replaceAll(oldVersion, newVersion);
|
||||||
|
//pkg.scripts["build-docker"] = pkg.scripts["build-docker"].replaceAll(oldVersion, newVersion);
|
||||||
|
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n");
|
||||||
|
|
||||||
|
// Process README.md
|
||||||
|
if (fs.existsSync("README.md")) {
|
||||||
|
fs.writeFileSync("README.md", fs.readFileSync("README.md", "utf8").replaceAll(oldVersion, newVersion));
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,6 @@ version: '3.8'
|
||||||
services:
|
services:
|
||||||
uptime-kuma:
|
uptime-kuma:
|
||||||
image: louislam/uptime-kuma:1
|
image: louislam/uptime-kuma:1
|
||||||
container_name: uptime-kuma
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -33,6 +33,12 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Require if mode is interactive
|
||||||
|
shell: {
|
||||||
|
type: String,
|
||||||
|
default: "bash",
|
||||||
|
},
|
||||||
|
|
||||||
rows: {
|
rows: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: TERMINAL_ROWS,
|
default: TERMINAL_ROWS,
|
||||||
|
@ -110,7 +116,7 @@ export default {
|
||||||
});
|
});
|
||||||
} else if (this.mode === "interactive") {
|
} else if (this.mode === "interactive") {
|
||||||
console.debug("Create Interactive terminal:", this.name);
|
console.debug("Create Interactive terminal:", this.name);
|
||||||
this.$root.getSocket().emit("interactiveTerminal", this.stackName, this.serviceName, (res) => {
|
this.$root.getSocket().emit("interactiveTerminal", this.stackName, this.serviceName, this.shell, (res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
this.$root.toastRes(res);
|
this.$root.toastRes(res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
⚠️ {{ $t("Frontend Version do not match backend version!") }}
|
⚠️ {{ $t("Frontend Version do not match backend version!") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="my-3 update-link"><a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">{{ $t("Check Update On GitHub") }}</a></div>
|
<div class="my-3 update-link"><a href="https://github.com/louislam/dockge/releases" target="_blank" rel="noopener">{{ $t("Check Update On GitHub") }}</a></div>
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<span class="fs-4 title">Dockge</span>
|
<span class="fs-4 title">Dockge</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<a v-if="hasNewVersion" target="_blank" href="https://github.com/louislam/uptime-kuma/releases" class="btn btn-info me-3">
|
<a v-if="hasNewVersion" target="_blank" href="https://github.com/louislam/dockge/releases" class="btn btn-info me-3">
|
||||||
<font-awesome-icon icon="arrow-alt-circle-up" /> {{ $t("New Update") }}
|
<font-awesome-icon icon="arrow-alt-circle-up" /> {{ $t("New Update") }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="slide-fade" appear>
|
<transition name="slide-fade" appear>
|
||||||
<div>
|
<div>
|
||||||
<h1 class="mb-3">Bash</h1>
|
<h1 class="mb-3">Terminal - {{ serviceName }} ({{ stackName }})</h1>
|
||||||
<p>
|
|
||||||
Stack: {{ stackName }}<br />
|
|
||||||
Container: {{ serviceName }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Terminal class="terminal" :rows="20" mode="interactive" :name="terminalName" :stack-name="stackName" :service-name="serviceName"></Terminal>
|
<div class="mb-3">
|
||||||
|
<router-link :to="sh" class="btn btn-normal me-2">Switch to sh</router-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Terminal class="terminal" :rows="20" mode="interactive" :name="terminalName" :stack-name="stackName" :service-name="serviceName" :shell="shell"></Terminal>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
@ -27,12 +27,25 @@ export default {
|
||||||
stackName() {
|
stackName() {
|
||||||
return this.$route.params.stackName;
|
return this.$route.params.stackName;
|
||||||
},
|
},
|
||||||
|
shell() {
|
||||||
|
return this.$route.params.type;
|
||||||
|
},
|
||||||
serviceName() {
|
serviceName() {
|
||||||
return this.$route.params.serviceName;
|
return this.$route.params.serviceName;
|
||||||
},
|
},
|
||||||
terminalName() {
|
terminalName() {
|
||||||
return getContainerExecTerminalName(this.stackName, this.serviceName, 0);
|
return getContainerExecTerminalName(this.stackName, this.serviceName, 0);
|
||||||
}
|
},
|
||||||
|
sh() {
|
||||||
|
return {
|
||||||
|
name: "containerTerminal",
|
||||||
|
params: {
|
||||||
|
stackName: this.stackName,
|
||||||
|
serviceName: this.serviceName,
|
||||||
|
type: "sh",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,9 @@ export default {
|
||||||
|
|
||||||
subMenus() {
|
subMenus() {
|
||||||
return {
|
return {
|
||||||
/*
|
|
||||||
general: {
|
general: {
|
||||||
title: this.$t("General"),
|
title: this.$t("General"),
|
||||||
},*/
|
},
|
||||||
appearance: {
|
appearance: {
|
||||||
title: this.$t("Appearance"),
|
title: this.$t("Appearance"),
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
"dev:frontend": "cross-env NODE_ENV=development vite --host --config ./frontend/vite.config.ts",
|
"dev:frontend": "cross-env NODE_ENV=development vite --host --config ./frontend/vite.config.ts",
|
||||||
"build:frontend": "vite build --config ./frontend/vite.config.ts",
|
"build:frontend": "vite build --config ./frontend/vite.config.ts",
|
||||||
"build:docker-base": "docker build -t louislam/dockge:base -f ./docker/Base.Dockerfile .",
|
"build:docker-base": "docker build -t louislam/dockge:base -f ./docker/Base.Dockerfile .",
|
||||||
"build:docker": "pnpm run build:frontend && docker build -t louislam/dockge:latest -f ./docker/Dockerfile .",
|
"build:docker": "pnpm run build:frontend && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:latest -f ./docker/Dockerfile . --push",
|
||||||
"start-docker": "docker run --rm -p 5001:5001 --name dockge louislam/dockge:latest"
|
"build:docker-nightly": "pnpm run build:frontend && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:nightly --target nightly -f ./docker/Dockerfile . --push",
|
||||||
|
"start-docker": "docker run --rm -p 5001:5001 --name dockge louislam/dockge:latest",
|
||||||
|
"mark-as-nightly": "tsx ./extra/mark-as-nightly.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@homebridge/node-pty-prebuilt-multiarch": "~0.11.7",
|
"@homebridge/node-pty-prebuilt-multiarch": "~0.11.7",
|
||||||
|
|
Loading…
Add table
Reference in a new issue