Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
egagli authored Jan 8, 2025
1 parent 37330fb commit d49cd8c
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d49cd8c

Please sign in to comment.