|
| 1 | +FROM ubuntu:20.04 |
| 2 | +# Ubuntu 20.04 comes with Python 3.8 |
| 3 | +ENV DEBIAN_FRONTEND noninteractive |
| 4 | +RUN apt-get update && \ |
| 5 | + apt-get install -y \ |
| 6 | + ca-certificates \ |
| 7 | + wget curl git-core \ |
| 8 | + vim-tiny zip unzip \ |
| 9 | + python3 python3-pip \ |
| 10 | + libssl-dev \ |
| 11 | + libmpdec2 \ |
| 12 | + proj-bin libproj-dev \ |
| 13 | + libgeos-dev libgeos++-dev \ |
| 14 | + mime-support \ |
| 15 | + gcc g++ \ |
| 16 | + cmake \ |
| 17 | + ncurses-term && \ |
| 18 | + apt-get clean && \ |
| 19 | + rm -rf /var/lib/apt/lists/ |
| 20 | + |
| 21 | +RUN ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color |
| 22 | + |
| 23 | +ENV PYTHONUNBUFFERED=1 \ |
| 24 | + PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ |
| 25 | + LANG=C.UTF-8 |
| 26 | + |
| 27 | +RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \ |
| 28 | + python3 -m pip install --no-cache-dir -U setuptools && \ |
| 29 | + python3 -m pip install --no-cache-dir h5py && \ |
| 30 | + python3 -m pip install --no-cache-dir Cython && \ |
| 31 | + python3 -m pip install --no-cache-dir matplotlib bokeh && \ |
| 32 | + python3 -m pip install --no-cache-dir versioneer && \ |
| 33 | + python3 -m pip install --no-cache-dir pyproj cartopy==0.19.0.post1 && \ |
| 34 | + python3 -m pip install --no-cache-dir pandas && \ |
| 35 | + python3 -m pip install --no-cache-dir seaborn && \ |
| 36 | + python3 -m pip install --no-cache-dir pillow && \ |
| 37 | + python3 -m pip install --no-cache-dir networkx cvxpy && \ |
| 38 | + python3 -m pip install --no-cache-dir scikit-learn scikit-image && \ |
| 39 | + python3 -m pip install --no-cache-dir pygments && \ |
| 40 | + python3 -m pip install --no-cache-dir ipython && \ |
| 41 | + python3 -m pip install --no-cache-dir jupyter && \ |
| 42 | + python3 -m pip install --no-cache-dir jupyterlab && \ |
| 43 | + rm -rf /root/.cache && \ |
| 44 | + rm -f /tmp/*.whl |
| 45 | +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2 |
| 46 | + |
| 47 | +# Install jupyter & Julia |
| 48 | +ARG JULIA_VERSION |
| 49 | +ENV JULIA_VERSION ${JULIA_VERSION:-1.8.5} |
| 50 | +ARG JULIA_MAJOR_VERSION |
| 51 | +ENV JULIA_MAJOR_VERSION ${JULIA_MAJOR_VERSION:-1.8} |
| 52 | +ENV JULIA_PATH "/usr/local/julia" |
| 53 | +ENV PATH $JULIA_PATH:$JULIA_PATH/bin:$PATH |
| 54 | + |
| 55 | +RUN dpkgArch="$(dpkg --print-architecture)"; \ |
| 56 | + case "${dpkgArch##*-}" in \ |
| 57 | + amd64) tarArch='x86_64'; dirArch='x64';; \ |
| 58 | + armhf) tarArch='arm'; dirArch='arm';; \ |
| 59 | + arm64) tarArch='aarch64'; dirArch='aarch64';; \ |
| 60 | + i386) tarArch='i686'; dirArch='x86';; \ |
| 61 | + *) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding Julia binary release"; exit 1 ;; \ |
| 62 | + esac; \ |
| 63 | + \ |
| 64 | + curl -fL -o julia.tar.gz "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"; \ |
| 65 | + \ |
| 66 | + mkdir "$JULIA_PATH"; \ |
| 67 | + tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1; \ |
| 68 | + rm julia.tar.gz |
| 69 | + |
| 70 | +#add IJulia package to make Julia kernel available in jupyter |
| 71 | +ENV JULIA_PKG_LOC /opt/julia |
| 72 | +ENV JULIA_LOAD_PATH :/opt/julia |
| 73 | +ENV JULIA_DEPOT_PATH /opt/julia |
| 74 | +RUN mkdir ${JULIA_PKG_LOC} |
| 75 | +RUN julia -e 'ENV["JUPYTER"]="jupyter"' && \ |
| 76 | + julia -e 'ENV["PYTHON"]="python3"' && \ |
| 77 | + julia -e 'ENV["JULIA_DEPOT_PATH"]="/opt/julia"' && \ |
| 78 | + julia -e 'using Pkg; Pkg.add("IJulia");' |
| 79 | + |
| 80 | +RUN julia -e 'using Pkg; Pkg.add("Plots"); using Plots;' |
| 81 | +RUN julia -e 'using Pkg; Pkg.add("DataFrames");' && \ |
| 82 | + julia -e 'using Pkg; Pkg.add("RDatasets");' && \ |
| 83 | + julia -e 'using Pkg; Pkg.add("PyPlot");' && \ |
| 84 | + julia -e 'using Pkg; Pkg.add("CSV");' && \ |
| 85 | + julia -e 'using Pkg; Pkg.add("Pandas"); using Pandas;' |
| 86 | + |
| 87 | +SHELL ["/bin/bash", "-c"] |
| 88 | +RUN julia -e 'using IJulia' && \ |
| 89 | + chmod -R 755 /opt/julia/compiled |
| 90 | +SHELL ["/bin/sh", "-c"] |
| 91 | +# Install ipython kernelspec |
| 92 | +COPY replace_placeholder.sh /etc/backend.ai/replace_placeholder.sh |
| 93 | +COPY kernel.json /usr/local/share/jupyter/kernels/julia-${JULIA_MAJOR_VERSION}/kernel.json |
| 94 | +RUN /etc/backend.ai/replace_placeholder.sh ${JULIA_MAJOR_VERSION} && \ |
| 95 | + rm /etc/backend.ai/replace_placeholder.sh |
| 96 | +COPY logo-32x32.png /usr/local/share/jupyter/kernels/julia-${JULIA_MAJOR_VERSION}/logo-32x32.png |
| 97 | +COPY logo-64x64.png /usr/local/share/jupyter/kernels/julia-${JULIA_MAJOR_VERSION}/logo-64x64.png |
| 98 | + |
| 99 | +# Backend.AI specifics |
| 100 | +LABEL ai.backend.kernelspec="1" \ |
| 101 | + ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \ |
| 102 | + ai.backend.features="batch query uid-match user-input" \ |
| 103 | + ai.backend.resource.min.cpu="1" \ |
| 104 | + ai.backend.resource.min.mem="1g" \ |
| 105 | + ai.backend.base-distro="ubuntu20.04" \ |
| 106 | + ai.backend.runtime-type="python" \ |
| 107 | + ai.backend.runtime-path="/usr/bin/python3" \ |
| 108 | + ai.backend.service-ports="ipython:pty:3000,jupyter:http:8070,jupyterlab:http:8090" |
| 109 | +COPY policy.yml /etc/backend.ai/jail/policy.yml |
| 110 | +ENV JULIA_DEPOT_PATH /home/work/.julia:/opt/julia |
| 111 | +ENV JULIA_PROJECT /home/work/.julia |
| 112 | +# vim: ft=dockerfile |
| 113 | + |
0 commit comments