mirror of
https://github.com/louislam/dockge.git
synced 2024-12-01 04:33:12 +01:00
wip
This commit is contained in:
parent
d7f4873405
commit
21e736459e
@ -11,7 +11,7 @@ export default obj;
|
||||
|
||||
// How much time in ms to wait between update checks
|
||||
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;
|
||||
|
||||
|
@ -16,7 +16,7 @@ interface DBConfig {
|
||||
|
||||
export class Database {
|
||||
/**
|
||||
* SQLite file path (Default: ./data/kuma.db)
|
||||
* SQLite file path (Default: ./data/dockge.db)
|
||||
* @type {string}
|
||||
*/
|
||||
static sqlitePath;
|
||||
|
@ -69,7 +69,7 @@ export class DockgeServer {
|
||||
// Catch unexpected errors here
|
||||
let unexpectedErrorHandler = (error : unknown) => {
|
||||
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("uncaughtException", unexpectedErrorHandler);
|
||||
|
@ -32,7 +32,7 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||
|
||||
let terminal = Terminal.getTerminal(terminalName);
|
||||
if (terminal instanceof InteractiveTerminal) {
|
||||
log.debug("terminalInput", "Terminal found, writing to terminal.");
|
||||
//log.debug("terminalInput", "Terminal found, writing to terminal.");
|
||||
terminal.write(cmd);
|
||||
} else {
|
||||
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
|
||||
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, callback) => {
|
||||
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, shell : unknown, callback) => {
|
||||
try {
|
||||
checkLogin(socket);
|
||||
|
||||
@ -91,12 +91,16 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||
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", "Service name: " + serviceName);
|
||||
|
||||
// Get stack
|
||||
const stack = Stack.getStack(server, stackName);
|
||||
stack.joinContainerTerminal(socket, serviceName);
|
||||
stack.joinContainerTerminal(socket, serviceName, shell);
|
||||
|
||||
callback({
|
||||
ok: true,
|
||||
|
@ -317,14 +317,14 @@ export class Stack {
|
||||
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);
|
||||
let terminal = Terminal.getTerminal(terminalName);
|
||||
|
||||
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;
|
||||
log.debug("deployStack", "Terminal created");
|
||||
log.debug("joinContainerTerminal", "Terminal created");
|
||||
}
|
||||
|
||||
terminal.join(socket);
|
||||
|
@ -98,12 +98,12 @@ export class Terminal {
|
||||
// Remove room
|
||||
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) {
|
||||
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
|
||||
WORKDIR /app
|
||||
COPY --chown=node:node . .
|
||||
@ -7,3 +10,10 @@ VOLUME /app/data
|
||||
EXPOSE 5001
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
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:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:1
|
||||
container_name: uptime-kuma
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
ports:
|
||||
|
@ -33,6 +33,12 @@ export default {
|
||||
type: String,
|
||||
},
|
||||
|
||||
// Require if mode is interactive
|
||||
shell: {
|
||||
type: String,
|
||||
default: "bash",
|
||||
},
|
||||
|
||||
rows: {
|
||||
type: Number,
|
||||
default: TERMINAL_ROWS,
|
||||
@ -110,7 +116,7 @@ export default {
|
||||
});
|
||||
} else if (this.mode === "interactive") {
|
||||
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) {
|
||||
this.$root.toastRes(res);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
⚠️ {{ $t("Frontend Version do not match backend version!") }}
|
||||
</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="form-check">
|
||||
|
@ -13,7 +13,7 @@
|
||||
<span class="fs-4 title">Dockge</span>
|
||||
</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") }}
|
||||
</a>
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<transition name="slide-fade" appear>
|
||||
<div>
|
||||
<h1 class="mb-3">Bash</h1>
|
||||
<p>
|
||||
Stack: {{ stackName }}<br />
|
||||
Container: {{ serviceName }}
|
||||
</p>
|
||||
<h1 class="mb-3">Terminal - {{ serviceName }} ({{ stackName }})</h1>
|
||||
|
||||
<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>
|
||||
</transition>
|
||||
</template>
|
||||
@ -27,12 +27,25 @@ export default {
|
||||
stackName() {
|
||||
return this.$route.params.stackName;
|
||||
},
|
||||
shell() {
|
||||
return this.$route.params.type;
|
||||
},
|
||||
serviceName() {
|
||||
return this.$route.params.serviceName;
|
||||
},
|
||||
terminalName() {
|
||||
return getContainerExecTerminalName(this.stackName, this.serviceName, 0);
|
||||
}
|
||||
},
|
||||
sh() {
|
||||
return {
|
||||
name: "containerTerminal",
|
||||
params: {
|
||||
stackName: this.stackName,
|
||||
serviceName: this.serviceName,
|
||||
type: "sh",
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
@ -74,10 +74,9 @@ export default {
|
||||
|
||||
subMenus() {
|
||||
return {
|
||||
/*
|
||||
general: {
|
||||
title: this.$t("General"),
|
||||
},*/
|
||||
},
|
||||
appearance: {
|
||||
title: this.$t("Appearance"),
|
||||
},
|
||||
|
@ -10,8 +10,10 @@
|
||||
"dev:frontend": "cross-env NODE_ENV=development vite --host --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": "pnpm run build:frontend && docker build -t louislam/dockge:latest -f ./docker/Dockerfile .",
|
||||
"start-docker": "docker run --rm -p 5001:5001 --name dockge louislam/dockge:latest"
|
||||
"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",
|
||||
"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": {
|
||||
"@homebridge/node-pty-prebuilt-multiarch": "~0.11.7",
|
||||
|
Loading…
Reference in New Issue
Block a user