mirror of
https://github.com/thomiceli/opengist.git
synced 2026-06-23 04:10:18 +00:00
Rootless docker (#716)
Go CI / Lint (push) Has been cancelled
Go CI / Check (push) Has been cancelled
Go CI / Test (mysql, 1.26, mysql:8, ubuntu-latest, 3306:3306) (push) Has been cancelled
Go CI / Test (postgres, 1.26, postgres:16, ubuntu-latest, 5432:5432) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, macOS-latest) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, macOS-latest) (push) Has been cancelled
Go CI / Build (1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, windows-latest) (push) Has been cancelled
Go CI / Lint (push) Has been cancelled
Go CI / Check (push) Has been cancelled
Go CI / Test (mysql, 1.26, mysql:8, ubuntu-latest, 3306:3306) (push) Has been cancelled
Go CI / Test (postgres, 1.26, postgres:16, ubuntu-latest, 5432:5432) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, macOS-latest) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, macOS-latest) (push) Has been cancelled
Go CI / Build (1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, windows-latest) (push) Has been cancelled
Signed-off-by: Thomas Miceli <tho.miceli@gmail.com>
This commit is contained in:
+14
-5
@@ -1,5 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
load_secrets() {
|
||||||
|
if [ -f "/run/secrets/opengist_secrets" ]; then
|
||||||
|
set -a
|
||||||
|
. /run/secrets/opengist_secrets
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
load_secrets
|
||||||
|
exec env HOME=/opengist OG_OPENGIST_HOME=/opengist /app/opengist/opengist --config /config.yml
|
||||||
|
fi
|
||||||
|
|
||||||
export USER=opengist
|
export USER=opengist
|
||||||
UID=${UID:-1000}
|
UID=${UID:-1000}
|
||||||
GID=${GID:-1000}
|
GID=${GID:-1000}
|
||||||
@@ -9,10 +22,6 @@ usermod -o -u "$UID" $USER
|
|||||||
chown -R "$USER:$USER" /opengist
|
chown -R "$USER:$USER" /opengist
|
||||||
chown -R "$USER:$USER" /config.yml
|
chown -R "$USER:$USER" /config.yml
|
||||||
|
|
||||||
if [ -f "/run/secrets/opengist_secrets" ]; then
|
load_secrets
|
||||||
set -a
|
|
||||||
. /run/secrets/opengist_secrets
|
|
||||||
set +a
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec su $USER -c "OG_OPENGIST_HOME=/opengist /app/opengist/opengist --config /config.yml"
|
exec su $USER -c "OG_OPENGIST_HOME=/opengist /app/opengist/opengist --config /config.yml"
|
||||||
|
|||||||
@@ -39,3 +39,28 @@ services:
|
|||||||
UID: 1001
|
UID: 1001
|
||||||
GID: 1001
|
GID: 1001
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Rootless
|
||||||
|
|
||||||
|
By default the container starts as `root` and the entrypoint drops privileges to the
|
||||||
|
user defined by `UID`/`GID` (see above).
|
||||||
|
|
||||||
|
If you'd rather have the container run as a
|
||||||
|
non-root user from the start — for example with `user:` in Compose, or under rootless
|
||||||
|
Docker/Podman — set the `user` key instead:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
services:
|
||||||
|
opengist:
|
||||||
|
# ...
|
||||||
|
user: "1001:1001"
|
||||||
|
volumes:
|
||||||
|
- "./opengist-data:/opengist"
|
||||||
|
```
|
||||||
|
|
||||||
|
In this mode the entrypoint runs Opengist directly as that user.
|
||||||
|
Create the Opengist data directory and own it on the host first:
|
||||||
|
```shell
|
||||||
|
mkdir -p ./opengist-data && sudo chown -R 1001:1001 ./opengist-data
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,11 @@ statefulSet:
|
|||||||
podSecurityContext:
|
podSecurityContext:
|
||||||
fsGroup: 1000
|
fsGroup: 1000
|
||||||
securityContext: {}
|
securityContext: {}
|
||||||
# allowPrivilegeEscalation: false
|
# runAsUser: 1000
|
||||||
|
# runAsGroup: 1000
|
||||||
|
# runAsNonRoot: true
|
||||||
|
# allowPrivilegeEscalation: false
|
||||||
|
# readOnlyRootFilesystem: true
|
||||||
|
|
||||||
## Pod Disruption Budget settings
|
## Pod Disruption Budget settings
|
||||||
## ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/
|
## ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/
|
||||||
|
|||||||
Reference in New Issue
Block a user