From d49cd8ceaf369759e0390b6441ff4e8d572d897b Mon Sep 17 00:00:00 2001 From: Eric Gagliano <67975937+egagli@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:20:29 -0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb03781..a4f0dd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,20 @@ # Dockerfile -FROM continuumio/miniconda3:latest - -# Create non-root user similar to jupyter's default 'jovyan' -RUN useradd -ms /bin/bash jovyan -USER root - -# Copy environment files -COPY environment.yml /tmp/environment.yml -COPY apt.txt /tmp/apt.txt +FROM jupyter/minimal-notebook:latest # Install system dependencies +COPY apt.txt /tmp/apt.txt +USER root RUN apt-get update && \ - grep -v '^#' /tmp/apt.txt | xargs apt-get install -y && \ + xargs apt-get install -y < /tmp/apt.txt && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Create conda environment and install jupyterlab -RUN conda env create -f /tmp/environment.yml && \ - conda install -n uwgda-image-living -c conda-forge jupyterlab && \ - conda clean -afy +# Switch back to jovyan user +USER ${NB_UID} -# Make RUN commands use the new conda environment -SHELL ["conda", "run", "-n", "uwgda-image-living", "/bin/bash", "-c"] - -# Set up conda env activation -RUN echo "conda activate uwgda-image-living" >> ~/.bashrc - -# Add conda environment to PATH and set CONDA_DEFAULT_ENV -ENV PATH /opt/conda/envs/uwgda-image-living/bin:$PATH -ENV CONDA_DEFAULT_ENV uwgda-image-living - -# Set up work directory and permissions -WORKDIR /home/jovyan -RUN chown -R jovyan:jovyan /home/jovyan - -# Switch to non-root user -USER jovyan - -# Expose Jupyter port -EXPOSE 8888 +# Copy environment.yml +COPY environment.yml /tmp/environment.yml -# Start JupyterLab using conda run to ensure we're in the right environment -ENTRYPOINT ["conda", "run", "-n", "uwgda-image-living"] -CMD ["jupyter", "lab", "--ip", "0.0.0.0", "--no-browser", "--ServerApp.token=''"] +# Create conda environment +RUN mamba env update -n base -f /tmp/environment.yml && \ + mamba clean --all -f -y