Set $USER environment variable in built images
Lots of code looks for this. This is generally set by PAM or
somesuch I believe. Let's set it explicitly!
MODIFY
repo2docker/buildpacks/base.py
repo2docker/buildpacks/base.py
@@ -32,6 +32,7 @@ ENV SHELL /bin/bash
# Set up user
ARG NB_USER
ARG NB_UID
+ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}
RUN adduser --disabled-password \

MODIFY
tests/users.py
tests/users.py
@@ -21,7 +21,7 @@ def test_user():
tmpdir,
'--',
'/bin/bash',
- '-c', 'id -u > id && pwd > pwd && whoami > name'.format(ts)
+ '-c', 'id -u > id && pwd > pwd && whoami > name && echo -n $USER > env_user'.format(ts)
])
with open(os.path.join(tmpdir, 'id')) as f:
@@ -30,3 +30,5 @@ def test_user():
assert f.read().strip() == '/home/yuvipanda'
with open(os.path.join(tmpdir, 'name')) as f:
assert f.read().strip() == 'yuvipanda'
+ with open(os.path.join(tmpdir, 'env_user')) as f:
+ assert f.read().strip() == 'yuvipanda'

Set $USER environment variable in built images

Lots of code looks for this. This is generally set by PAM or
somesuch I believe. Let's set it explicitly!