Compare commits

..

3 Commits

Author SHA1 Message Date
5ed6bd9982 WIP 2023-11-25 17:07:53 +08:00
875793d6c2 Merge branch 'master' into rollout 2023-11-25 15:39:37 +08:00
e9c8abf759 Add Docker Rollout 2023-11-25 00:27:16 +08:00
19 changed files with 125 additions and 201 deletions

View File

@ -14,8 +14,8 @@ jobs:
ci:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, ARM64]
node: [18.17.1] # Can be changed
os: [ubuntu-latest, windows-latest, macos-latest]
node: [20.x] # Can be changed
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code

View File

@ -1,16 +0,0 @@
name: Prevent File Change
on:
pull_request:
jobs:
check-file-changes:
runs-on: ubuntu-latest
steps:
- name: Prevent file change
uses: xalvarez/prevent-file-change-action@v1
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Regex, /src/lang/*.json is not allowed to be changed, except for /src/lang/en.json
pattern: '^(?!frontend/src/lang/en\.json$)frontend/src/lang/.*\.json$'
trustedAuthors: UptimeKumaBot

View File

@ -7,15 +7,13 @@ Here are some references:
### ✅ Usually accepted:
- Bug fix
- Security fix
- Adding new language files (see [these instructions](https://github.com/louislam/dockge/blob/master/frontend/src/lang/README.md))
- Adding new language keys: `$t("...")`
- Translation
### ⚠️ Discussion required:
- Large pull requests
- New features
### ❌ Won't be merged:
- A dedicated PR for translating existing languages (see [these instructions](https://github.com/louislam/dockge/blob/master/frontend/src/lang/README.md))
- Do not pass the auto-test
- Any breaking changes
- Duplicated pull requests

View File

@ -48,14 +48,14 @@ Requirements:
- Default Port: 5001
```
# Create directories that store your stacks and stores Dockge's stack
# Create a directory that stores your stacks and stores dockge's compose.yaml
mkdir -p /opt/stacks /opt/dockge
cd /opt/dockge
# Download the compose.yaml
curl https://raw.githubusercontent.com/louislam/dockge/master/compose.yaml --output compose.yaml
# Start the server
# Start the Server
docker compose up -d
# If you are using docker-compose V1 or Podman
@ -66,27 +66,40 @@ Dockge is now running on http://localhost:5001
### Advanced
If you want to store your stacks in another directory, you can generate your compose.yaml file by using the following URL with custom query strings.
If you want to store your stacks in another directory, you can change the `DOCKGE_STACKS_DIR` environment variable and volumes.
```yaml
version: "3.8"
services:
dockge:
image: louislam/dockge:1
restart: unless-stopped
ports:
# Host Port : Container Port
- 5001:5001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/app/data
# If you want to use private registries, you need to share the auth file with Dockge:
# - /root/.docker/:/root/.docker
# Your stacks directory in the host (The paths inside container must be the same as the host)
# ⚠️⚠️ If you did it wrong, your data could end up be written into a wrong path.
# ✔️✔️✔️✔️ CORRECT: - /my-stacks:/my-stacks (Both paths match)
# ❌❌❌❌ WRONG: - /docker:/my-stacks (Both paths do not match)
- /opt/stacks:/opt/stacks
environment:
# Tell Dockge where is your stacks directory
- DOCKGE_STACKS_DIR=/opt/stacks
```
# Download your compose.yaml
curl "https://dockge.kuma.pet/compose.yaml?port=5001&stacksPath=/opt/stacks" --output compose.yaml
```
- port=`5001`
- stacksPath=`/opt/stacks`
Interactive compose.yaml generator is available on:
https://dockge.kuma.pet
You can also view compose.yaml here:
https://github.com/louislam/dockge/blob/master/compose.yaml
## How to Update
```bash
cd /opt/dockge
docker compose pull && docker compose up -d
docker compose pull
docker compose up -d
```
## Screenshots

View File

@ -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
socket.on("downStack", async (stackName : unknown, callback) => {
try {

View File

@ -323,6 +323,21 @@ export class Stack {
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> {
const terminalName = getComposeTerminalName(this.name);
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "stop" ], this.path);

View File

@ -5,6 +5,8 @@ import { LimitQueue } from "./utils/limit-queue";
import { DockgeSocket } from "./util-server";
import {
allowedCommandList, allowedRawKeys,
getComposeTerminalName,
getCryptoRandomInt,
PROGRESS_TERMINAL_ROWS,
TERMINAL_COLS,
TERMINAL_ROWS
@ -205,20 +207,14 @@ export class Terminal {
}
public static exec(server : DockgeServer, socket : DockgeSocket | undefined, terminalName : string, file : string, args : string | string[], cwd : string) : Promise<number> {
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;
}
const terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;
let terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;
if (socket) {
terminal.join(socket);
}
if (socket) {
terminal.join(socket);
}
return new Promise((resolve) => {
terminal.onExit((exitCode : number) => {
resolve(exitCode);
});

View File

@ -1,7 +1,9 @@
# Due to the bug of #145, Node.js's version cannot be changed, unless upstream is fixed.
FROM node:18.17.1-bookworm-slim
FROM node:20-bookworm-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
RUN apt update && apt install --yes --no-install-recommends \
curl \
ca-certificates \
@ -22,3 +24,9 @@ RUN apt update && apt install --yes --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& npm install pnpm -g \
&& pnpm install -g tsx
# Install docker rollout plugin \
RUN mkdir -p ~/.docker/cli-plugins \
&& curl https://raw.githubusercontent.com/wowu/docker-rollout/master/docker-rollout -o ~/.docker/cli-plugins/docker-rollout \
&& chmod +x ~/.docker/cli-plugins/docker-rollout \
&& docker rollout --help

View File

@ -30,10 +30,6 @@ export default {
displayName: {
type: String,
required: true,
},
objectType: {
type: String,
default: "service",
}
},
data() {
@ -45,7 +41,8 @@ export default {
array() {
// Create the array if not exists, it should be safe.
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];
},
@ -59,24 +56,8 @@ export default {
return this.service[this.name] !== undefined;
},
/**
* Not a good name, but it is used to get the object.
*/
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 {};
}
return this.$parent.$parent.service;
},
valid() {
@ -100,19 +81,6 @@ 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,7 +49,8 @@ export default {
array() {
// Create the array if not exists, it should be safe.
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];
},
@ -88,10 +89,6 @@ 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

@ -54,6 +54,7 @@ import {
faTerminal, faWarehouse, faHome, faRocket,
faRotate,
faCloudArrowDown, faArrowsRotate,
faPaintRoller,
} from "@fortawesome/free-solid-svg-icons";
library.add(
@ -109,6 +110,7 @@ library.add(
faRotate,
faCloudArrowDown,
faArrowsRotate,
faPaintRoller,
);
export { FontAwesomeIcon };

View File

@ -2,18 +2,13 @@
A simple guide on how to translate `Dockge` in your native language.
## How to Translate
(11-26-2023) Updated
1. Go to <https://weblate.kuma.pet>
2. Register an account on Weblate
3. Make sure your GitHub email is matched with Weblate's account, so that it could show you as a contributor on GitHub
4. Choose your language on Weblate and start translating.
## How to add a new language in the dropdown
1. Add your Language at <https://weblate.kuma.pet/projects/dockge/dockge/>.
2. Find the language code (You can find it at the end of the URL)
(11-21-2023) Updated
1. Add your Language at `frontend/src/lang/` by creating a new file with your language Code, format: `zh-TW.json` .
2. Copy the content from `en.json` and make translations from that.
3. Add your language at the end of `languageList` in `frontend/src/i18n.ts`, format: `"zh-TW": "繁體中文 (台灣)"`,
4. Commit to new branch and make a new Pull Request for me to approve.
*Note:* Currently we are only accepting one Pull Request per Language Translate.

View File

@ -20,6 +20,7 @@
"updateStack": "Update",
"startStack": "Start",
"downStack": "Stop & Down",
"rolloutStack": "Rollout Update (Zero Downtime)",
"editStack": "Edit",
"discardStack": "Discard",
"saveStackDraft": "Save",
@ -91,12 +92,5 @@
"Allowed commands:": "Allowed commands:",
"Internal Networks": "Internal Networks",
"External Networks": "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",
"extra": "Extra"
"No External Networks": "No External Networks"
}

View File

@ -12,7 +12,7 @@
"registry": "رجسٹری",
"compose": "تحریر",
"addFirstStackMsg": "اپنا پہلا اسٹیک کمپوز کریں!",
"stackName": "اسٹیک کا نام",
"stackName" : "اسٹیک کا نام",
"deployStack": "تعینات",
"deleteStack": "حذف کریں",
"stopStack": "روکو",
@ -22,7 +22,7 @@
"editStack": "ترمیم",
"discardStack": "رد کر دیں۔",
"saveStackDraft": "محفوظ کریں۔",
"notAvailableShort": "N / A",
"notAvailableShort" : "N / A",
"deleteStackMsg": "کیا آپ واقعی اس اسٹیک کو حذف کرنا چاہتے ہیں؟",
"stackNotManagedByDockgeMsg": "یہ اسٹیک Dockge کے زیر انتظام نہیں ہے۔",
"primaryHostname": "بنیادی میزبان نام",
@ -90,13 +90,5 @@
"Allowed commands:": "اجازت شدہ احکامات:",
"Internal Networks": "اندرونی نیٹ ورکس",
"External Networks": "بیرونی نیٹ ورکس",
"No External Networks": "کوئی بیرونی نیٹ ورک نہیں",
"reverseProxyMsg1": "ایک ریورس پراکسی کا استعمال کرتے ہوئے؟",
"Cannot connect to the socket server.": "ساکٹ سرور سے منسلک نہیں ہو سکتا۔",
"reconnecting...": "دوبارہ منسلک ہو رہا ہے...",
"connecting...": "ساکٹ سرور سے منسلک ہو رہا ہے...",
"url": "یو آر ایل | یو آر ایل",
"extra": "اضافی",
"downStack": "اسٹاپ اینڈ ڈاؤن",
"reverseProxyMsg2": "اسے WebSocket کے لیے ترتیب دینے کا طریقہ چیک کریں"
"No External Networks": "کوئی بیرونی نیٹ ورک نہیں"
}

View File

@ -12,7 +12,7 @@
"registry": "镜像仓库",
"compose": "Compose",
"addFirstStackMsg": "组合你的第一个堆栈!",
"stackName": "堆栈名称",
"stackName" : "堆栈名称",
"deployStack": "部署",
"deleteStack": "删除",
"stopStack": "停止",
@ -22,7 +22,7 @@
"editStack": "编辑",
"discardStack": "放弃",
"saveStackDraft": "保存",
"notAvailableShort": "不可用",
"notAvailableShort" : "不可用",
"deleteStackMsg": "你确定要删除这个堆栈吗?",
"stackNotManagedByDockgeMsg": "这个堆栈不由Dockge管理",
"primaryHostname": "主机名",
@ -90,10 +90,5 @@
"Allowed commands:": "允许使用的指令:",
"Internal Networks": "内部网络",
"External Networks": "外部网络",
"No External Networks": "无外部网络",
"reconnecting...": "重连中...",
"reverseProxyMsg2": "检查如何配置WebSocket",
"reverseProxyMsg1": "正在使用反向代理?",
"connecting...": "正在连接到socket服务器...",
"Cannot connect to the socket server.": "无法连接到socket服务器。"
"No External Networks": "无外部网络"
}

View File

@ -3,9 +3,6 @@
<div v-if="! $root.socketIO.connected && ! $root.socketIO.firstConnect" class="lost-connection">
<div class="container-fluid">
{{ $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>
@ -85,10 +82,6 @@
</header>
<main>
<div v-if="$root.socketIO.connecting" class="container mt-5">
<h4>{{ $t("connecting...") }}</h4>
</div>
<router-view v-if="$root.loggedIn" />
<Login v-if="! $root.loggedIn && $root.allowLoginDialog" />
</main>

View File

@ -19,7 +19,6 @@ export default defineComponent({
initedSocketIO: false,
connectionErrorMsg: `${this.$t("Cannot connect to the socket server.")} ${this.$t("Reconnecting...")}`,
showReverseProxyGuide: true,
connecting: false,
},
info: {
@ -104,10 +103,6 @@ export default defineComponent({
url = location.protocol + "//" + location.host;
}
let connectingMsgTimeout = setTimeout(() => {
this.socketIO.connecting = true;
}, 1500);
socket = io(url, {
transports: [ "websocket", "polling" ]
});
@ -115,9 +110,6 @@ export default defineComponent({
socket.on("connect", () => {
console.log("Connected to the socket server");
clearTimeout(connectingMsgTimeout);
this.socketIO.connecting = false;
this.socketIO.connectCount++;
this.socketIO.connected = true;
this.socketIO.showReverseProxyGuide = false;
@ -151,11 +143,10 @@ export default defineComponent({
socket.on("connect_error", (err) => {
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.connected = false;
this.socketIO.firstConnect = false;
this.socketIO.connecting = false;
});
// Custom Events

View File

@ -41,11 +41,15 @@
{{ $t("stopStack") }}
</button>
<BDropdown right text="" variant="normal">
<BDropdownItem @click="downStack">
<BDropdown v-if="!isEditMode || active" right text="" variant="normal">
<BDropdownItem v-if="!isEditMode" @click="downStack">
<font-awesome-icon icon="stop" class="me-1" />
{{ $t("downStack") }}
</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>
</div>
@ -56,13 +60,6 @@
</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
@ -118,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>
<!-- 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>
@ -273,34 +256,6 @@ 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;
},
@ -535,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() {
this.processing = true;

View File

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