Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Admin password #735

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4fe1625
Update reset-password.ts
laurentlemercier Feb 11, 2024
be72cdb
Update compose.yaml
laurentlemercier Feb 11, 2024
ff92223
Update reset-password.ts
laurentlemercier Feb 11, 2024
9615b84
Update reset-password.ts
laurentlemercier Feb 11, 2024
c451067
Update reset-password.ts
laurentlemercier Mar 10, 2024
d5e8f17
Update reset-password.ts
laurentlemercier Mar 10, 2024
8533d18
Update reset-password.ts
laurentlemercier Mar 10, 2024
165a944
Update reset-password.ts
laurentlemercier Mar 10, 2024
93f2278
Added Irish language (#425)
aindriu80 Feb 12, 2024
f81677f
Update json-yaml-validate to latest version (#446)
GrantBirki Mar 13, 2024
14eebf6
docker compose `version` is obsolete (#473)
oddysee Apr 20, 2024
4ae9ee2
fix default compose version obsolete (#507)
cyril59310 May 1, 2024
6f9e26f
Fixed: An agent do not disconnect correctly after removed (#617)
DomiiBunn Oct 13, 2024
d397122
Added translation using Weblate (Norwegian Bokmål)
Eventyret Jan 22, 2024
07068f3
Translated using Weblate (Arabic)
Faisalalali Jan 21, 2024
f82b4f8
Translated using Weblate (Swedish)
GunnarNorin Jan 22, 2024
f0e3126
Translated using Weblate (Thai)
kiznick Jan 22, 2024
c4c2b89
Translated using Weblate (Indonesian)
NexiaMoe Jan 22, 2024
26e8605
Translated using Weblate (Norwegian Bokmål)
Eventyret Jan 22, 2024
e8917af
Translated using Weblate (Thai)
kiznick Jan 23, 2024
975a01e
Translated using Weblate (Portuguese (Brazil))
altendorfme Feb 1, 2024
cfef1af
Translated using Weblate (Portuguese)
CosmoAbdon Feb 3, 2024
c1527c4
Translated using Weblate (Danish)
letterlock Feb 7, 2024
f4220b6
Added translation using Weblate (Irish)
aindriu80 Feb 9, 2024
c22bd99
Translated using Weblate (Irish)
aindriu80 Feb 9, 2024
327e7b5
Translated using Weblate (Spanish)
djismgaming Feb 11, 2024
af73218
Translated using Weblate (Hungarian)
gergepalfi Mar 5, 2024
5de3999
Translated using Weblate (Arabic)
ahmedtalaltwd7 Mar 21, 2024
3a50961
Translated using Weblate (Turkish)
DogukanK Mar 22, 2024
874a300
Translated using Weblate (Catalan)
pacoculebras Mar 25, 2024
b875f20
Translated using Weblate (Slovenian)
rumplin May 12, 2024
e907b5a
Translated using Weblate (Polish)
er2de2 May 16, 2024
5948ba2
Translated using Weblate (Dutch)
brmvnml May 17, 2024
04bf2a5
Added translation using Weblate (Belarusian)
k1llo Jun 21, 2024
efb85a7
Translated using Weblate (Belarusian)
k1llo Jun 21, 2024
7470c03
Translated using Weblate (Italian)
mikeleord Jul 11, 2024
2b89a06
Translated using Weblate (Ukrainian)
stanol Jul 10, 2024
0b5ed33
Translated using Weblate (Hungarian)
MatyiFKBT Jul 18, 2024
d6b5f98
Translated using Weblate (German)
teatower Aug 10, 2024
db543a5
Translated using Weblate (Hungarian)
gergepalfi Sep 18, 2024
9717f94
Add Translation keys (#506)
cyril59310 Oct 13, 2024
ea518d8
Update dependencies
louislam Oct 13, 2024
3b857c9
Update to Node.js 22 from 18, as the upstream cpu 100% issues has bee…
louislam Oct 13, 2024
9c237d0
Update css for terminal
louislam Oct 13, 2024
f685a67
Pin node-pty-prebuilt-multiarch
louislam Oct 13, 2024
f058b4e
Also update ci's node version to 22
louislam Oct 13, 2024
ed2b927
Add ARMv7 for CI
louislam Oct 14, 2024
7843b99
Remove the tsx workaround as it had been fixed in upstream
louislam Dec 26, 2024
0b72272
Update dependencies
louislam Dec 26, 2024
0f0cee7
Remove useless scrollbar (#642)
cyril59310 Dec 31, 2024
0e59e6e
fix bug 176: preserve YAML comments when reordering items by matching…
turnah Dec 31, 2024
db68c86
Update dependencies
louislam Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, ARM, ARM64]
node: [22] # Can be changed
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/json-yaml-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
json-yaml-validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: json-yaml-validate
id: json-yaml-validate
uses: GrantBirki/json-yaml-validate@v1.3.0
uses: GrantBirki/json-yaml-validate@v2.6.1
with:
comment: "false" # enable comment mode
exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions
2 changes: 2 additions & 0 deletions backend/agent-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export class AgentManager {
if (bean) {
await R.trash(bean);
let endpoint = bean.endpoint;
this.disconnect(endpoint);
this.sendAgentList();
delete this.agentSocketList[endpoint];
} else {
throw new Error("Agent not found");
Expand Down
25 changes: 17 additions & 8 deletions backend/agent-socket-handlers/docker-socket-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class DockerSocketHandler extends AgentSocketHandler {
callbackResult({
ok: true,
msg: "Deployed",
msgi18n: true,
}, callback);
stack.joinCombinedTerminal(socket);
} catch (e) {
Expand All @@ -30,7 +31,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await this.saveStack(server, name, composeYAML, composeENV, isAdd);
callbackResult({
ok: true,
"msg": "Saved"
msg: "Saved",
msgi18n: true,
}, callback);
server.sendStackList();
} catch (e) {
Expand All @@ -56,7 +58,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
server.sendStackList();
callbackResult({
ok: true,
msg: "Deleted"
msg: "Deleted",
msgi18n: true,
}, callback);

} catch (e) {
Expand Down Expand Up @@ -94,7 +97,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
server.sendStackList();
callbackResult({
ok: true,
msg: "Updated"
msg: "Updated",
msgi18n: true,
}, callback);
} catch (e) {
callbackError(e, callback);
Expand All @@ -114,7 +118,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await stack.start(socket);
callbackResult({
ok: true,
msg: "Started"
msg: "Started",
msgi18n: true,
}, callback);
server.sendStackList();

Expand All @@ -138,7 +143,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await stack.stop(socket);
callbackResult({
ok: true,
msg: "Stopped"
msg: "Stopped",
msgi18n: true,
}, callback);
server.sendStackList();
} catch (e) {
Expand All @@ -159,7 +165,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await stack.restart(socket);
callbackResult({
ok: true,
msg: "Restarted"
msg: "Restarted",
msgi18n: true,
}, callback);
server.sendStackList();
} catch (e) {
Expand All @@ -180,7 +187,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await stack.update(socket);
callbackResult({
ok: true,
msg: "Updated"
msg: "Updated",
msgi18n: true,
}, callback);
server.sendStackList();
} catch (e) {
Expand All @@ -201,7 +209,8 @@ export class DockerSocketHandler extends AgentSocketHandler {
await stack.down(socket);
callbackResult({
ok: true,
msg: "Downed"
msg: "Downed",
msgi18n: true,
}, callback);
server.sendStackList();
} catch (e) {
Expand Down
63 changes: 42 additions & 21 deletions common/util-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,42 +236,63 @@ export function copyYAMLComments(doc : Document, src : Document) {

/**
* Copy yaml comments from srcItems to items
* Typescript is super annoying here, so I have to use any here
* TODO: Since comments are belong to the array index, the comments will be lost if the order of the items is changed or removed or added.
* Attempts to preserve comments by matching content rather than just array indices
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function copyYAMLCommentsItems(items : any, srcItems : any) {
function copyYAMLCommentsItems(items: any, srcItems: any) {
if (!items || !srcItems) {
return;
}

// First pass - try to match items by their content
for (let i = 0; i < items.length; i++) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const item : any = items[i];
const item: any = items[i];

// Try to find matching source item by content
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const srcItem : any = srcItems[i];
const srcIndex = srcItems.findIndex((srcItem: any) =>
JSON.stringify(srcItem.value) === JSON.stringify(item.value) &&
JSON.stringify(srcItem.key) === JSON.stringify(item.key)
);

if (srcIndex !== -1) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const srcItem: any = srcItems[srcIndex];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const nextSrcItem: any = srcItems[srcIndex + 1];

if (item.key && srcItem.key) {
item.key.comment = srcItem.key.comment;
item.key.commentBefore = srcItem.key.commentBefore;
}

if (!srcItem) {
continue;
}
if (srcItem.comment) {
item.comment = srcItem.comment;
}

if (item.key && srcItem.key) {
item.key.comment = srcItem.key.comment;
item.key.commentBefore = srcItem.key.commentBefore;
}
// Handle comments between array items
if (nextSrcItem && nextSrcItem.commentBefore) {
if (items[i + 1]) {
items[i + 1].commentBefore = nextSrcItem.commentBefore;
}
}

if (srcItem.comment) {
item.comment = srcItem.comment;
}
// Handle trailing comments after array items
if (srcItem.value && srcItem.value.comment) {
if (item.value) {
item.value.comment = srcItem.value.comment;
}
}

if (item.value && srcItem.value) {
if (typeof item.value === "object" && typeof srcItem.value === "object") {
item.value.comment = srcItem.value.comment;
item.value.commentBefore = srcItem.value.commentBefore;
if (item.value && srcItem.value) {
if (typeof item.value === "object" && typeof srcItem.value === "object") {
item.value.comment = srcItem.value.comment;
item.value.commentBefore = srcItem.value.commentBefore;

if (item.value.items && srcItem.value.items) {
copyYAMLCommentsItems(item.value.items, srcItem.value.items);
if (item.value.items && srcItem.value.items) {
copyYAMLCommentsItems(item.value.items, srcItem.value.items);
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:
dockge:
image: louislam/dockge:1
Expand All @@ -21,3 +20,6 @@ services:
environment:
# Tell Dockge where is your stacks directory
- DOCKGE_STACKS_DIR=/opt/stacks
# Usefull for interactive action within the container
stdin_open: true # docker run -i
tty: true # docker run -t
3 changes: 1 addition & 2 deletions docker/Base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 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:22-bookworm-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apt update && apt install --yes --no-install-recommends \
Expand Down
9 changes: 8 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ COPY --from=build /app/node_modules /app/node_modules
COPY --chown=node:node . .
RUN mkdir ./data


# It is just for safe, as by default, it is disabled in the latest Node.js now.
# Read more:
# - https://github.com/sagemathinc/cocalc/issues/6963
# - https://github.com/microsoft/node-pty/issues/630#issuecomment-1987212447
ENV UV_USE_IO_URING=0

VOLUME /app/data
EXPOSE 5001
HEALTHCHECK --interval=60s --timeout=30s --start-period=60s --retries=5 CMD extra/healthcheck
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["bash", "-c", "node ./extra/clean-tsx-tmp.js && tsx ./backend/index.ts"]
CMD ["tsx", "./backend/index.ts"]

############################################
# Mark as Nightly
Expand Down
13 changes: 0 additions & 13 deletions extra/clean-tsx-tmp.js

This file was deleted.

70 changes: 52 additions & 18 deletions extra/reset-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DockgeServer } from "../backend/dockge-server";
import { log } from "../backend/log";
import { io } from "socket.io-client";
import { BaseRes } from "../common/util-common";
import { generatePasswordHash } from "../backend/password-hash";

console.log("== Dockge Reset Password Tool ==");

Expand All @@ -29,35 +30,67 @@ export const main = async () => {
}

try {
let user ;
// No need to actually reset the password for testing, just make sure no connection problem. It is ok for now.

if (!process.env.TEST_BACKEND) {
const user = await R.findOne("user");
if (! user) {
throw new Error("user not found, have you installed?");
user = await R.findOne("user");

if (! user ) {
if ( !process.env.USER ) {
throw new Error("user not found or provided, have you installed? Try to set USER and PASSWORD variables ...");
} else {
console.log("Trying to initialise user : " + process.env.USER);
user = R.dispense("user");
user.username = process.env.USER;
user.password = generatePasswordHash(process.env.PASSWORD);
await R.store(user);
console.log("User/Password set successfully");

// Reset all sessions by reset jwt secret
await server.initJWTSecret();
console.log("JWT reset successfully.");

// Disconnect all other socket clients of the user
await disconnectAllSocketClients(user.username, user.password);
console.log("You may have to restart");
exit;
}
}
}

console.log("Found user: " + user.username);
let password = "";
let confirmPassword = " ";

while (true) {
let password = await question("New Password: ");
let confirmPassword = await question("Confirm New Password: ");
while (true) {

if (password === confirmPassword) {
await User.resetPassword(user.id, password);
if (process.env.PASSWORD) {
console.log("Found password : " + process.env.PASSWORD) ;
password = process.env.PASSWORD ;
confirmPassword = process.env.PASSWORD ;
} else {
console.log("No found password: " ) ;
password = await question("New Password: ");
confirmPassword = await question("Confirm New Password: ");
}

// Reset all sessions by reset jwt secret
await server.initJWTSecret();
if (password === confirmPassword) {
await User.resetPassword(user.id, password);
console.log("Password reset successfully.");

console.log("Password reset successfully.");
// Reset all sessions by reset jwt secret
await server.initJWTSecret();

// Disconnect all other socket clients of the user
await disconnectAllSocketClients(user.username, password);
console.log("JWT reset successfully.");

break;
} else {
console.log("Passwords do not match, please try again.");
}
// Disconnect all other socket clients of the user
await disconnectAllSocketClients(user.username, password);

} else {
console.log("Passwords do not match, please try again.");
break;
}
break;
}
} catch (e) {
if (e instanceof Error) {
Expand Down Expand Up @@ -127,3 +160,4 @@ function disconnectAllSocketClients(username : string, password : string) : Prom
if (!process.env.TEST_BACKEND) {
main();
}

1 change: 0 additions & 1 deletion extra/templates/mariadb/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:
mariadb:
image: mariadb:latest
Expand Down
1 change: 0 additions & 1 deletion extra/templates/nginx-proxy-manager/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
nginx-proxy-manager:
image: 'jc21/nginx-proxy-manager:latest'
Expand Down
1 change: 0 additions & 1 deletion extra/templates/uptime-kuma/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
uptime-kuma:
image: louislam/uptime-kuma:1
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ArraySelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ul v-if="isArrayInited" class="list-group">
<li v-for="(value, index) in array" :key="index" class="list-group-item">
<select v-model="array[index]" class="no-bg domain-input">
<option value="">Select a network...</option>
<option value="">{{ $t(`Select a network...`) }}</option>
<option v-for="option in options" :key="option" :value="option">{{ option }}</option>
</select>

Expand Down
Loading
Loading