mirror of
https://github.com/louislam/dockge.git
synced 2025-08-19 23:38:40 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5ed6bd9982 | ||
|
875793d6c2 | ||
|
e9c8abf759 |
@@ -195,7 +195,6 @@ export class DockgeServer {
|
|||||||
// Create Socket.io
|
// Create Socket.io
|
||||||
this.io = new socketIO.Server(this.httpServer, {
|
this.io = new socketIO.Server(this.httpServer, {
|
||||||
cors,
|
cors,
|
||||||
transports: [ "websocket" ],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.io.on("connection", async (socket: Socket) => {
|
this.io.on("connection", async (socket: Socket) => {
|
||||||
|
@@ -189,6 +189,28 @@ export class DockerSocketHandler extends SocketHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// rolloutStack
|
||||||
|
socket.on("rolloutStack", async (stackName : unknown, callback) => {
|
||||||
|
try {
|
||||||
|
checkLogin(socket);
|
||||||
|
|
||||||
|
if (typeof(stackName) !== "string") {
|
||||||
|
throw new ValidationError("Stack name must be a string");
|
||||||
|
}
|
||||||
|
|
||||||
|
const stack = Stack.getStack(server, stackName);
|
||||||
|
await stack.rollout(socket);
|
||||||
|
callback({
|
||||||
|
ok: true,
|
||||||
|
msg: "Rolled out"
|
||||||
|
});
|
||||||
|
server.sendStackList();
|
||||||
|
stack.joinCombinedTerminal(socket);
|
||||||
|
} catch (e) {
|
||||||
|
callbackError(e, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// down stack
|
// down stack
|
||||||
socket.on("downStack", async (stackName : unknown, callback) => {
|
socket.on("downStack", async (stackName : unknown, callback) => {
|
||||||
try {
|
try {
|
||||||
|
@@ -323,6 +323,21 @@ export class Stack {
|
|||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async rollout(socket: DockgeSocket) {
|
||||||
|
let terminalName = getComposeTerminalName(this.name);
|
||||||
|
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "pull" ], this.path);
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
throw new Error("Failed to pull, please check the terminal output for more information.");
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalName = getComposeTerminalName(this.name);
|
||||||
|
exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "rollout", this.name ], this.path);
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
throw new Error("Failed to rollout, please check the terminal output for more information.");
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
async stop(socket: DockgeSocket) : Promise<number> {
|
async stop(socket: DockgeSocket) : Promise<number> {
|
||||||
const terminalName = getComposeTerminalName(this.name);
|
const terminalName = getComposeTerminalName(this.name);
|
||||||
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "stop" ], this.path);
|
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "stop" ], this.path);
|
||||||
|
@@ -25,15 +25,8 @@ RUN apt update && apt install --yes --no-install-recommends \
|
|||||||
&& npm install pnpm -g \
|
&& npm install pnpm -g \
|
||||||
&& pnpm install -g tsx
|
&& pnpm install -g tsx
|
||||||
|
|
||||||
# ensures that /var/run/docker.sock exists
|
# Install docker rollout plugin \
|
||||||
# changes the ownership of /var/run/docker.sock
|
RUN mkdir -p ~/.docker/cli-plugins \
|
||||||
RUN touch /var/run/docker.sock && chown node:node /var/run/docker.sock
|
&& curl https://raw.githubusercontent.com/wowu/docker-rollout/master/docker-rollout -o ~/.docker/cli-plugins/docker-rollout \
|
||||||
|
&& chmod +x ~/.docker/cli-plugins/docker-rollout \
|
||||||
# Full Base Image
|
&& docker rollout --help
|
||||||
# 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
|
|
||||||
|
@@ -30,10 +30,6 @@ export default {
|
|||||||
displayName: {
|
displayName: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
|
||||||
objectType: {
|
|
||||||
type: String,
|
|
||||||
default: "service",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -45,7 +41,8 @@ export default {
|
|||||||
array() {
|
array() {
|
||||||
// Create the array if not exists, it should be safe.
|
// Create the array if not exists, it should be safe.
|
||||||
if (!this.service[this.name]) {
|
if (!this.service[this.name]) {
|
||||||
return [];
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||||
|
this.service[this.name] = [];
|
||||||
}
|
}
|
||||||
return this.service[this.name];
|
return this.service[this.name];
|
||||||
},
|
},
|
||||||
@@ -59,24 +56,8 @@ export default {
|
|||||||
return this.service[this.name] !== undefined;
|
return this.service[this.name] !== undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Not a good name, but it is used to get the object.
|
|
||||||
*/
|
|
||||||
service() {
|
service() {
|
||||||
if (this.objectType === "service") {
|
return this.$parent.$parent.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() {
|
valid() {
|
||||||
@@ -100,19 +81,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addField() {
|
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("");
|
this.array.push("");
|
||||||
},
|
},
|
||||||
remove(index) {
|
remove(index) {
|
||||||
|
@@ -49,7 +49,8 @@ export default {
|
|||||||
array() {
|
array() {
|
||||||
// Create the array if not exists, it should be safe.
|
// Create the array if not exists, it should be safe.
|
||||||
if (!this.service[this.name]) {
|
if (!this.service[this.name]) {
|
||||||
return [];
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||||
|
this.service[this.name] = [];
|
||||||
}
|
}
|
||||||
return this.service[this.name];
|
return this.service[this.name];
|
||||||
},
|
},
|
||||||
@@ -88,10 +89,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addField() {
|
addField() {
|
||||||
// Create the array if not exists.
|
|
||||||
if (!this.service[this.name]) {
|
|
||||||
this.service[this.name] = [];
|
|
||||||
}
|
|
||||||
this.array.push("");
|
this.array.push("");
|
||||||
},
|
},
|
||||||
remove(index) {
|
remove(index) {
|
||||||
|
@@ -54,6 +54,7 @@ import {
|
|||||||
faTerminal, faWarehouse, faHome, faRocket,
|
faTerminal, faWarehouse, faHome, faRocket,
|
||||||
faRotate,
|
faRotate,
|
||||||
faCloudArrowDown, faArrowsRotate,
|
faCloudArrowDown, faArrowsRotate,
|
||||||
|
faPaintRoller,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
@@ -109,6 +110,7 @@ library.add(
|
|||||||
faRotate,
|
faRotate,
|
||||||
faCloudArrowDown,
|
faCloudArrowDown,
|
||||||
faArrowsRotate,
|
faArrowsRotate,
|
||||||
|
faPaintRoller,
|
||||||
);
|
);
|
||||||
|
|
||||||
export { FontAwesomeIcon };
|
export { FontAwesomeIcon };
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"updateStack": "Update",
|
"updateStack": "Update",
|
||||||
"startStack": "Start",
|
"startStack": "Start",
|
||||||
"downStack": "Stop & Down",
|
"downStack": "Stop & Down",
|
||||||
|
"rolloutStack": "Rollout Update (Zero Downtime)",
|
||||||
"editStack": "Edit",
|
"editStack": "Edit",
|
||||||
"discardStack": "Discard",
|
"discardStack": "Discard",
|
||||||
"saveStackDraft": "Save",
|
"saveStackDraft": "Save",
|
||||||
@@ -91,11 +92,5 @@
|
|||||||
"Allowed commands:": "Allowed commands:",
|
"Allowed commands:": "Allowed commands:",
|
||||||
"Internal Networks": "Internal Networks",
|
"Internal Networks": "Internal Networks",
|
||||||
"External Networks": "External Networks",
|
"External Networks": "External Networks",
|
||||||
"No External Networks": "No External Networks",
|
"No External Networks": "No External Networks"
|
||||||
"reverseProxyMsg1": "Using a Reverse Proxy?",
|
|
||||||
"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...",
|
|
||||||
"url": "URL | URLs"
|
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,6 @@
|
|||||||
<div v-if="! $root.socketIO.connected && ! $root.socketIO.firstConnect" class="lost-connection">
|
<div v-if="! $root.socketIO.connected && ! $root.socketIO.firstConnect" class="lost-connection">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
{{ $root.socketIO.connectionErrorMsg }}
|
{{ $root.socketIO.connectionErrorMsg }}
|
||||||
<div v-if="$root.socketIO.showReverseProxyGuide">
|
|
||||||
{{ $t("reverseProxyMsg1") }} <a href="https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy" target="_blank">{{ $t("reverseProxyMsg2") }}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,10 +82,6 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div v-if="$root.socketIO.connecting" class="container mt-5">
|
|
||||||
<h4>{{ $t("connecting...") }}</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<router-view v-if="$root.loggedIn" />
|
<router-view v-if="$root.loggedIn" />
|
||||||
<Login v-if="! $root.loggedIn && $root.allowLoginDialog" />
|
<Login v-if="! $root.loggedIn && $root.allowLoginDialog" />
|
||||||
</main>
|
</main>
|
||||||
|
@@ -19,7 +19,6 @@ export default defineComponent({
|
|||||||
initedSocketIO: false,
|
initedSocketIO: false,
|
||||||
connectionErrorMsg: `${this.$t("Cannot connect to the socket server.")} ${this.$t("Reconnecting...")}`,
|
connectionErrorMsg: `${this.$t("Cannot connect to the socket server.")} ${this.$t("Reconnecting...")}`,
|
||||||
showReverseProxyGuide: true,
|
showReverseProxyGuide: true,
|
||||||
connecting: false,
|
|
||||||
},
|
},
|
||||||
info: {
|
info: {
|
||||||
|
|
||||||
@@ -104,20 +103,13 @@ export default defineComponent({
|
|||||||
url = location.protocol + "//" + location.host;
|
url = location.protocol + "//" + location.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
let connectingMsgTimeout = setTimeout(() => {
|
|
||||||
this.socketIO.connecting = true;
|
|
||||||
}, 1500);
|
|
||||||
|
|
||||||
socket = io(url, {
|
socket = io(url, {
|
||||||
transports: [ "websocket" ]
|
transports: [ "websocket", "polling" ]
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
console.log("Connected to the socket server");
|
console.log("Connected to the socket server");
|
||||||
|
|
||||||
clearTimeout(connectingMsgTimeout);
|
|
||||||
this.socketIO.connecting = false;
|
|
||||||
|
|
||||||
this.socketIO.connectCount++;
|
this.socketIO.connectCount++;
|
||||||
this.socketIO.connected = true;
|
this.socketIO.connected = true;
|
||||||
this.socketIO.showReverseProxyGuide = false;
|
this.socketIO.showReverseProxyGuide = false;
|
||||||
@@ -151,11 +143,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
socket.on("connect_error", (err) => {
|
socket.on("connect_error", (err) => {
|
||||||
console.error(`Failed to connect to the backend. Socket.io connect_error: ${err.message}`);
|
console.error(`Failed to connect to the backend. Socket.io connect_error: ${err.message}`);
|
||||||
this.socketIO.connectionErrorMsg = `${this.$t("Cannot connect to the socket server.")} [${err}] ${this.$t("reconnecting...")}`;
|
this.socketIO.connectionErrorMsg = `${this.$t("Cannot connect to the socket server.")} [${err}] ${this.$t("Reconnecting...")}`;
|
||||||
this.socketIO.showReverseProxyGuide = true;
|
this.socketIO.showReverseProxyGuide = true;
|
||||||
this.socketIO.connected = false;
|
this.socketIO.connected = false;
|
||||||
this.socketIO.firstConnect = false;
|
this.socketIO.firstConnect = false;
|
||||||
this.socketIO.connecting = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Custom Events
|
// Custom Events
|
||||||
|
@@ -41,11 +41,15 @@
|
|||||||
{{ $t("stopStack") }}
|
{{ $t("stopStack") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<BDropdown right text="" variant="normal">
|
<BDropdown v-if="!isEditMode || active" right text="" variant="normal">
|
||||||
<BDropdownItem @click="downStack">
|
<BDropdownItem v-if="!isEditMode" @click="downStack">
|
||||||
<font-awesome-icon icon="stop" class="me-1" />
|
<font-awesome-icon icon="stop" class="me-1" />
|
||||||
{{ $t("downStack") }}
|
{{ $t("downStack") }}
|
||||||
</BDropdownItem>
|
</BDropdownItem>
|
||||||
|
<BDropdownItem v-if="active" @click="rolloutStack">
|
||||||
|
<font-awesome-icon icon="paint-roller" class="me-1" />
|
||||||
|
{{ $t("rolloutStack") }} <span class="badge bg-info">Beta</span>
|
||||||
|
</BDropdownItem>
|
||||||
</BDropdown>
|
</BDropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -56,13 +60,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</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 -->
|
<!-- Progress Terminal -->
|
||||||
<transition name="slide-fade" appear>
|
<transition name="slide-fade" appear>
|
||||||
<Terminal
|
<Terminal
|
||||||
@@ -87,14 +84,6 @@
|
|||||||
<input id="name" v-model="stack.name" type="text" class="form-control" required @blur="stackNameToLowercase">
|
<input id="name" v-model="stack.name" type="text" class="form-control" required @blur="stackNameToLowercase">
|
||||||
<div class="form-text">{{ $t("Lowercase only") }}</div>
|
<div class="form-text">{{ $t("Lowercase only") }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -126,20 +115,6 @@
|
|||||||
|
|
||||||
<button v-if="false && isEditMode && jsonConfig.services && Object.keys(jsonConfig.services).length > 0" class="btn btn-normal mb-3" @click="addContainer">{{ $t("addContainer") }}</button>
|
<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 -->
|
<!-- Combined Terminal Output -->
|
||||||
<div v-show="!isEditMode">
|
<div v-show="!isEditMode">
|
||||||
<h4 class="mb-3">Terminal</h4>
|
<h4 class="mb-3">Terminal</h4>
|
||||||
@@ -281,34 +256,6 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
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() {
|
isAdd() {
|
||||||
return this.$route.path === "/compose" && !this.submitted;
|
return this.$route.path === "/compose" && !this.submitted;
|
||||||
},
|
},
|
||||||
@@ -543,6 +490,15 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
rolloutStack() {
|
||||||
|
this.processing = true;
|
||||||
|
|
||||||
|
this.$root.getSocket().emit("rolloutStack", this.stack.name, (res) => {
|
||||||
|
this.processing = false;
|
||||||
|
this.$root.toastRes(res);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
downStack() {
|
downStack() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user