diff --git a/README.md b/README.md index a6ecad04ef4e3abbc25911eb5287551870887367..61905927fac75399b8e149e46c7b0d1904b0f234 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ __NOTE__: It is possible to use the notebooks directly from some IDEs like [VSCo It is possible to execute the notebooks from a Docker machine by simply: ``` -docker run -p 8888:8888 registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp:latest +docker run -v $PWD:/home/formation/gettingstartedwithmoderncpp -p 8888:8888 registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp:latest ``` The simply in your browser just simply go to [http://localhost:8888/](http://localhost:8888/). diff --git a/docker/Dockerfile b/docker/Dockerfile index 22f6e6c567a9d449ebe2cfb3ffc3da42753099fa..89f3102604d7a0fde4f1af5d5eed6f6449ada03d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,58 +1,22 @@ -# Each instruction in this file generates a new layer that gets pushed to your local image cache +# Inspired from https://pythonspeed.com/articles/activate-conda-dockerfile +FROM continuumio/miniconda3 -# Lines preceeded by # are regarded as comments and ignored +LABEL maintainer Vicente Mataix Ferrandiz "vicente.mataix-ferrandiz@inria.fr" and Sébastien Gilles "sebastien.gilles@inria.fr" -# The line below states we will base our new image on the Latest Official Ubuntu -FROM ubuntu:latest - -# Identify the maintainer of an image -LABEL maintainer="vicente.mataix-ferrandiz@inria.fr" - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get -y clean -RUN apt-get -y update -RUN apt-get -y upgrade -RUN apt-get install -y \ - nano \ - bash \ - wget \ - curl \ - git \ - cmake \ - clang \ - build-essential && \ - apt-get autoremove -y -RUN apt-get -y clean - -# Creation of a "non-root" user +# Create non root user and give him the ownership of /opt/conda. ENV USER "formation" RUN useradd --create-home ${USER} +RUN chown ${USER}:${USER} /opt/conda USER ${USER} -# Default working directory is -WORKDIR /home/${USER} -RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -RUN bash Miniconda3-latest-Linux-x86_64.sh -b -RUN rm -rf Miniconda3-latest-Linux-x86_64.sh - -# Changing to home -WORKDIR /home/${USER} -RUN git clone https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp.git +# Create the environment: +WORKDIR /home/${USER}/gettingstartedwithmoderncpp +COPY environment.yml . +RUN conda env create -f environment.yml -# Change the default shell to be bash +# Make RUN commands use the new environment: SHELL ["/bin/bash", "-c"] -# Conda environment -WORKDIR /home/${USER}/gettingstartedwithmoderncpp -# RUN echo ". /home/${USER}/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc -RUN /home/${USER}/miniconda3/bin/conda env create -f environment.yml -RUN /home/${USER}/miniconda3/bin/conda init bash -# RUN source ~/.bashrc -RUN source /home/${USER}/miniconda3/etc/profile.d/conda.sh -RUN /home/${USER}/miniconda3/bin/conda clean -a - -# Add to the bashrc -RUN echo "alias python=\"python3\"" >> ~/.bashrc -RUN echo "conda activate training_cpp_2021" >> ~/.bashrc -RUN source ~/.bashrc -CMD ["/home/formation/miniconda3/bin/conda", "run", "-n", "training_cpp_2021", "jupyter", "lab", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root","--NotebookApp.token=''"] +# The code to run when container is started: +# Using informations from https://hub.docker.com/r/continuumio/miniconda3 and options used by Vicente in former Docker file based on Ubuntu. +ENTRYPOINT [ "conda", "run", "--no-capture-output", "-n", "training_cpp_2021", "jupyter", "lab", "--port=8888", "--ip=0.0.0.0", "--no-browser","--allow-root","--NotebookApp.token=''"] \ No newline at end of file