A non-numeric PUID or PGID makes the [ -ne ] comparison error out, so usermod
is skipped and the app silently runs as the default UID 1000 instead of the
requested one. PUID 0 is worse: the container starts as root and drops to the
"app" user via gosu, so a PUID of 0 leaves that user at uid 0, the "am I still
root?" check never turns false, and the entrypoint re-execs itself forever.
Reject both up front with a clear message.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Kubernetes sets a Docker-style service-link variable for every Service that
exists in the namespace when a pod starts, so a Service named "spoolman" makes
SPOOLMAN_PORT=tcp://<clusterIP>:8000 inside the container. That is the Service
address, not a port, and uvicorn refuses to start on it, so the pod crashloops
- seemingly at random, since it only happens when the Service predates the pod.
Ignore the service-link form and keep the default port.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This change enables the container to run in unprivileged mode (without
--privileged or additional capabilities) by making permission drops
conditional:
- Changed users group GID from 1000 to 1001 to avoid conflicts with
the app user's primary group (UID 1000)
- Only modify user/group IDs when PUID/PGID environment variables differ
from the default value of 1000, avoiding unnecessary privilege
requirements
- Skip su-exec entirely when running as the default user, since changing
user context requires additional capabilities that unprivileged
containers don't have
This allows the container to work in restricted environments like
Kubernetes with security contexts or rootless Docker while maintaining
backward compatibility for users who customize PUID/PGID.
Fixes Donkie#791