From a2cb012e65e06ef49dc8730b2ac7d20b7d916b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 25 Oct 2019 10:38:15 +0200 Subject: [PATCH] Fix dev user creation when running root on host --- tutor/templates/build/openedx-dev/Dockerfile | 9 ++++----- tutor/templates/build/openedx-dev/bin/create-user.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100755 tutor/templates/build/openedx-dev/bin/create-user.sh diff --git a/tutor/templates/build/openedx-dev/Dockerfile b/tutor/templates/build/openedx-dev/Dockerfile index 5170f85..49ead48 100644 --- a/tutor/templates/build/openedx-dev/Dockerfile +++ b/tutor/templates/build/openedx-dev/Dockerfile @@ -10,15 +10,14 @@ RUN apt update && \ RUN pip install -r requirements/edx/development.txt RUN pip install ipdb==0.12.2 ipython==5.8.0 -# Configure new user -ARG USERID=1000 -RUN useradd --home-dir /openedx --uid $USERID openedx -RUN chown -R openedx:openedx /openedx - # Copy new entrypoint (to take care of permission issues at runtime) COPY ./bin /openedx/bin RUN chmod a+x /openedx/bin/* +# Configure new user +ARG USERID=1000 +RUN create-user.sh $USERID + # Default django settings ENV SETTINGS tutor.development diff --git a/tutor/templates/build/openedx-dev/bin/create-user.sh b/tutor/templates/build/openedx-dev/bin/create-user.sh new file mode 100755 index 0000000..4b91302 --- /dev/null +++ b/tutor/templates/build/openedx-dev/bin/create-user.sh @@ -0,0 +1,11 @@ +#! /bin/sh -e +USERID=$1 + +if [ "$USERID" != "" ] && [ "$USERID" != "0" ] +then + echo "Creating 'openedx' user with id $USERID" + useradd --home-dir /openedx --uid $USERID openedx + chown -R openedx:openedx /openedx +else + echo "Running as root" +fi \ No newline at end of file