From c51f595ee827d1292c100993a8cf4c4e876efe4d Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 10 Jan 2018 15:43:03 -0500 Subject: [PATCH] Allow the uid and gid to be customizeable Change-Id: Ib6fd0da0020ec71a9d70d96501b40e849c004531 --- Dockerfile | 3 +++ README.md | 2 ++ scripts/create_user.sh | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ede35de..3953a27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,9 @@ ARG PIP_PACKAGES="" ARG PLUGIN=no ARG PYTHON3=no +ARG UID=42424 +ARG GID=42424 + COPY scripts /opt/loci/scripts COPY bindep.txt /opt/loci/ diff --git a/README.md b/README.md index 40c96bc..1cc3966 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ For more advanced building you can use docker build arguments to define: should contain * `PROJECT_REF` The git ref, branch, or tag the container should fetch for the project + * `UID` The uid of the user that will be created (defaults to 42424). + * `GID` The gid of the group that will be created (default to 42424). * `WHEELS` The location of the wheels tarball. This accepts a url to a tarball or a Docker image name in the form of [myregistry/]mydockernamespace/requirements[:ubuntu] diff --git a/scripts/create_user.sh b/scripts/create_user.sh index 7ba28af..417875d 100755 --- a/scripts/create_user.sh +++ b/scripts/create_user.sh @@ -2,8 +2,8 @@ set -ex -groupadd -g 42424 ${PROJECT} -useradd -u 42424 -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT} +groupadd -g ${GID} ${PROJECT} +useradd -u ${UID} -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT} mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}