From 9f6a3eea322f66cdc3fe12d4016106a7c92ba5bb Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sun, 19 Nov 2023 19:18:41 +0000 Subject: [PATCH 1/2] chown stacks to this user --- README.md | 3 +++ backend/stack.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 4d7b08bc..a8ca22c2 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ services: environment: # Tell Dockge where is your stacks directory - DOCKGE_STACKS_DIR=/opt/stacks + # Both PUID and PGID must be set for it to do anything + - PUID=1000 # Set the stack file/dir ownership to this user + - PGID=1000 # Set the stack file/dir ownership to this group ``` ## How to Update diff --git a/backend/stack.ts b/backend/stack.ts index 922dad89..a535e04a 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -147,6 +147,13 @@ export class Stack { // Write or overwrite the compose.yaml fs.writeFileSync(path.join(dir, this._composeFileName), this.composeYAML); + if(process.env.PUID && process.env.PGID) + { + var uid: number = Number(process.env.PUID); + var gid: number = Number(process.env.PGID); + fs.lchownSync(dir, uid, gid); + fs.chownSync(path.join(dir, this._composeFileName), uid, gid); + } } async deploy(socket? : DockgeSocket) : Promise { From a4ea716ee83ead697ec22cf908680f4b3c7d1ca8 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sun, 19 Nov 2023 22:50:35 +0000 Subject: [PATCH 2/2] Fix linting issues --- backend/stack.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/stack.ts b/backend/stack.ts index a535e04a..26b49ca2 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -147,10 +147,9 @@ export class Stack { // Write or overwrite the compose.yaml fs.writeFileSync(path.join(dir, this._composeFileName), this.composeYAML); - if(process.env.PUID && process.env.PGID) - { - var uid: number = Number(process.env.PUID); - var gid: number = Number(process.env.PGID); + if (process.env.PUID && process.env.PGID) { + const uid = Number(process.env.PUID); + const gid = Number(process.env.PGID); fs.lchownSync(dir, uid, gid); fs.chownSync(path.join(dir, this._composeFileName), uid, gid); }