|
1 | 1 | # Dockerfile
|
2 |
| -FROM continuumio/miniconda3:latest |
3 |
| - |
4 |
| -# Create non-root user similar to jupyter's default 'jovyan' |
5 |
| -RUN useradd -ms /bin/bash jovyan |
6 |
| -USER root |
7 |
| - |
8 |
| -# Copy environment files |
9 |
| -COPY environment.yml /tmp/environment.yml |
10 |
| -COPY apt.txt /tmp/apt.txt |
| 2 | +FROM jupyter/minimal-notebook:latest |
11 | 3 |
|
12 | 4 | # Install system dependencies
|
| 5 | +COPY apt.txt /tmp/apt.txt |
| 6 | +USER root |
13 | 7 | RUN apt-get update && \
|
14 |
| - grep -v '^#' /tmp/apt.txt | xargs apt-get install -y && \ |
| 8 | + xargs apt-get install -y < /tmp/apt.txt && \ |
15 | 9 | apt-get clean && \
|
16 | 10 | rm -rf /var/lib/apt/lists/*
|
17 | 11 |
|
18 |
| -# Create conda environment and install jupyterlab |
19 |
| -RUN conda env create -f /tmp/environment.yml && \ |
20 |
| - conda install -n uwgda-image-living -c conda-forge jupyterlab && \ |
21 |
| - conda clean -afy |
| 12 | +# Switch back to jovyan user |
| 13 | +USER ${NB_UID} |
22 | 14 |
|
23 |
| -# Make RUN commands use the new conda environment |
24 |
| -SHELL ["conda", "run", "-n", "uwgda-image-living", "/bin/bash", "-c"] |
25 |
| - |
26 |
| -# Set up conda env activation |
27 |
| -RUN echo "conda activate uwgda-image-living" >> ~/.bashrc |
28 |
| - |
29 |
| -# Add conda environment to PATH and set CONDA_DEFAULT_ENV |
30 |
| -ENV PATH /opt/conda/envs/uwgda-image-living/bin:$PATH |
31 |
| -ENV CONDA_DEFAULT_ENV uwgda-image-living |
32 |
| - |
33 |
| -# Set up work directory and permissions |
34 |
| -WORKDIR /home/jovyan |
35 |
| -RUN chown -R jovyan:jovyan /home/jovyan |
36 |
| - |
37 |
| -# Switch to non-root user |
38 |
| -USER jovyan |
39 |
| - |
40 |
| -# Expose Jupyter port |
41 |
| -EXPOSE 8888 |
| 15 | +# Copy environment.yml |
| 16 | +COPY environment.yml /tmp/environment.yml |
42 | 17 |
|
43 |
| -# Start JupyterLab using conda run to ensure we're in the right environment |
44 |
| -ENTRYPOINT ["conda", "run", "-n", "uwgda-image-living"] |
45 |
| -CMD ["jupyter", "lab", "--ip", "0.0.0.0", "--no-browser", "--ServerApp.token=''"] |
| 18 | +# Create conda environment |
| 19 | +RUN mamba env update -n base -f /tmp/environment.yml && \ |
| 20 | + mamba clean --all -f -y |
0 commit comments