Commit 5bc8eb18 authored by Peter Parente's avatar Peter Parente

Make jovyan name / paths constant

parent 701212db
...@@ -26,12 +26,8 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \ ...@@ -26,12 +26,8 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \
sudo \ sudo \
&& apt-get clean && apt-get clean
# Configure docker environment # Configure environment
ENV CONDA_DIR /opt/conda ENV CONDA_DIR /opt/conda
ENV NB_USER jovyan
ENV NB_HOME /home/$NB_USER
ENV NB_WORK $NB_HOME/work
ENV WORK $NB_WORK
ENV PATH $CONDA_DIR/bin:$PATH ENV PATH $CONDA_DIR/bin:$PATH
# Install conda # Install conda
......
[program:notebook] [program:notebook]
user=jovyan user=jovyan
umask=0002 umask=0002
directory=%(ENV_WORK)s directory=/home/jovyan/work
command=ipython notebook command=ipython notebook
autostart=true autostart=true
autorestart=true autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log stdout_logfile=/var/log/supervisor/%(program_name)s.log
redirect_stderr=true redirect_stderr=true
environment=HOME="/home/%(ENV_NB_USER)s",USER="%(ENV_NB_USER)s" environment=HOME="/home/jovyan",USER="jovyan",SHELL="/bin/bash"
#!/bin/bash #!/bin/bash
# Constants
NB_USER=jovyan
NB_HOME=/home/$NB_USER
NB_WORK=$NB_HOME/work
# Create non-root NB_USER if one doesn't exist # Create non-root NB_USER if one doesn't exist
id -u $NB_USER && user_exists=true id -u $NB_USER && user_exists=true
if [ -z "$user_exists" ] ; then if [ -z "$user_exists" ] ; then
useradd -m -s /bin/bash -u ${NB_UID:-1000} $NB_USER useradd -m -s /bin/bash -u ${NB_UID:-1000} $NB_USER
# Setup a work directory rooted in the NB_USER home # Setup a work directory rooted in the NB_USER home
mkdir -p $WORK mkdir -p $NB_WORK
chown -R jovyan.jovyan $NB_HOME chown -R $NB_USER.$NB_USER $NB_HOME
# Allow "jovyan" group to update conda root env # Allow NB_USER group to update conda root env
chown -R root.jovyan $CONDA_DIR chown -R root.$NB_USER $CONDA_DIR
chmod g+w $CONDA_DIR chmod g+w $CONDA_DIR
fi fi
# Copy skeleton files if useradd didn't do it (e.g., volume mounted dir # Copy skeleton files if useradd didn't do it (e.g., volume mounted dir
# residing in /home/jovyan prevented it) # residing in NB_HOME prevented it)
if [ ! -d $NB_HOME/.jupyter ]; then if [ ! -d $NB_HOME/.jupyter ]; then
cp -r /etc/skel/. $NB_HOME cp -r /etc/skel/. $NB_HOME
chown -R jovyan.jovyan $NB_HOME chown -R $NB_USER.$NB_USER $NB_HOME
fi fi
# Enable sudo if requested # Enable sudo if requested
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment