This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/training.git
The following commit(s) were added to refs/heads/develop by this push:
new 2dda992 fix: Added a script that makes docker build using the local
users uid and gid, hopefully resolving permission issues on Jenkins.
2dda992 is described below
commit 2dda99216f7f64ce5e225e3d36eb698134cab405
Author: Christofer Dutz <[email protected]>
AuthorDate: Sat Aug 30 16:27:37 2025 +0200
fix: Added a script that makes docker build using the local users uid and
gid, hopefully resolving permission issues on Jenkins.
---
Dockerfile | 12 ++++++----
docker/entrypoint.sh | 28 ++++++++++++++++++++++
.../requirements-legacy.txt | 0
.../requirements-modern.txt | 0
4 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index c8eadd6..99541f5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -54,7 +54,8 @@ RUN apt-get update \
python3-gi \
gir1.2-gtk-4.0 \
dos2unix \
- build-essential \
+ build-essential \
+ gosu \
&& rm -rf /var/lib/apt/lists/*
# -------------------------
@@ -71,8 +72,8 @@ RUN cargo install svgbob_cli --version "${SVGBOB_VERSION}"
--locked \
# -------------------------
# Python
# -------------------------
-COPY requirements-legacy.txt /tmp/requirements-legacy.txt
-COPY requirements-modern.txt /tmp/requirements-modern.txt
+COPY docker/requirements-legacy.txt /tmp/requirements-legacy.txt
+COPY docker/requirements-modern.txt /tmp/requirements-modern.txt
# 1) Ensure old setuptools is present and *kept* for legacy packages
RUN python3 -m pip install --no-cache-dir "pip==24.2" "setuptools==57.5.0"
"wheel<0.40"
@@ -130,4 +131,7 @@ RUN python3 -m pip freeze > /requirements-frozen.txt
# -------------------------
# Final touches
# -------------------------
-WORKDIR /ws
+COPY docker/entrypoint.sh /usr/local/bin/entrypoint
+RUN chmod +x /usr/local/bin/entrypoint
+ENTRYPOINT ["/usr/local/bin/entrypoint"]
+WORKDIR /ws
\ No newline at end of file
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100644
index 0000000..aa08536
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+WS_DIR=${WS_DIR:-/ws}
+
+# Detect host uid/gid of the bind mount; default to 1000 if unknown
+HOST_UID=$(stat -c '%u' "$WS_DIR" 2>/dev/null || echo 1000)
+HOST_GID=$(stat -c '%g' "$WS_DIR" 2>/dev/null || echo 1000)
+
+# If the bind mount is owned by root (0), allow env overrides; else use stat
values
+if [ "$HOST_UID" = "0" ] && [ "${UID:-}" != "" ]; then HOST_UID="$UID"; fi
+if [ "$HOST_GID" = "0" ] && [ "${GID:-}" != "" ]; then HOST_GID="$GID"; fi
+if [ "$HOST_UID" = "0" ]; then HOST_UID=1000; fi
+if [ "$HOST_GID" = "0" ]; then HOST_GID=1000; fi
+
+# Create group/user if missing (ids-only; no home needed)
+if ! getent group "$HOST_GID" >/dev/null; then groupadd -g "$HOST_GID"
hostgrp; fi
+if ! id -u "$HOST_UID" >/dev/null 2>&1; then useradd -u "$HOST_UID" -g
"$HOST_GID" -M -s /bin/bash hostusr; fi
+
+# Ensure a writable HOME inside the bind mount for tools writing dotfiles
+export HOME="$WS_DIR/.home"
+mkdir -p "$HOME"
+
+# Prefer Maven repo inside the workspace unless caller overrides
+export MAVEN_CONFIG="${MAVEN_CONFIG:-$HOME/.m2}"
+
+# Exec final command as host uid:gid
+exec gosu "$HOST_UID:$HOST_GID" "$@"
diff --git a/requirements-legacy.txt b/docker/requirements-legacy.txt
similarity index 100%
rename from requirements-legacy.txt
rename to docker/requirements-legacy.txt
diff --git a/requirements-modern.txt b/docker/requirements-modern.txt
similarity index 100%
rename from requirements-modern.txt
rename to docker/requirements-modern.txt