Skip to content

Instantly share code, notes, and snippets.

@jtfogarty
Last active October 26, 2018 20:52
Show Gist options
  • Save jtfogarty/9b7295edfabe3b94176c2582ce62ec17 to your computer and use it in GitHub Desktop.
Save jtfogarty/9b7295edfabe3b94176c2582ce62ec17 to your computer and use it in GitHub Desktop.
FROM 007ba7/usb-rapid-02
USER root
# R pre-requisites
RUN apt-get update && \
apt-get install -y --no-install-recommends \
fonts-dejavu \
tzdata \
gfortran \
gcc && apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Julia dependencies
# install Julia packages in /opt/julia instead of $HOME
ENV JULIA_PKGDIR=/opt/julia
ENV JULIA_VERSION=1.0.1
ENV CONDA_DIR=/conda
#COPY ./julia-1.0.1-linux-x86_64.tar.gz /tmp/julia-1.0.1-linux-x86_64.tar.gz
RUN mkdir /opt/julia-${JULIA_VERSION} && \
cd /tmp && \
wget -q https://julialang-s3.julialang.org/bin/linux/x64/`echo ${JULIA_VERSION} | cut -d. -f 1,2`/julia-${JULIA_VERSION}-linux-x86_64.tar.gz && \
# echo "bea4570d7358016d8ed29d2c15787dbefaea3e746c570763e7ad6040f17831f3 *julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | sha256sum -c - && \
tar xzf julia-${JULIA_VERSION}-linux-x86_64.tar.gz -C /opt/julia-${JULIA_VERSION} --strip-components=1 && \
rm /tmp/julia-${JULIA_VERSION}-linux-x86_64.tar.gz
RUN ln -fs /opt/julia-*/bin/julia /usr/local/bin/julia
# Show Julia where conda libraries are \
RUN mkdir /etc/julia && \
echo "push!(Libdl.DL_LOAD_PATH, \"$CONDA_DIR/lib\")" >> /etc/julia/juliarc.jl && \
# Create JULIA_PKGDIR \
mkdir $JULIA_PKGDIR && \
chown $NB_USER $JULIA_PKGDIR && \
# fix-permissions $JULIA_PKGDIR
chown -R ${NB_USER}:users $JULIA_PKGDIR
USER $NB_UID
RUN echo $NB_UID
# Add Julia packages. Only add HDF5 if this is not a test-only build since
# it takes roughly half the entire build time of all of the images on Travis
# to add this one package and often causes Travis to timeout.
#
# Install IJulia as jovyan and then move the kernelspec out
# to the system share location. Avoids problems with runtime UID change not
# taking effect properly on the .local folder in the jovyan home dir.
RUN julia -e 'import Pkg; Pkg.update()' && \
(test $TEST_ONLY_BUILD || julia -e 'import Pkg; Pkg.add("HDF5")') && \
julia -e 'import Pkg; Pkg.add("Gadfly")' && \
julia -e 'import Pkg; Pkg.add("RDatasets")' && \
julia -e 'import Pkg; Pkg.add("IJulia")' && \
# Precompile Julia packages \
julia -e 'using IJulia' && \
# move kernelspec out of home \
mv $HOME/.local/share/jupyter/kernels/julia* $CONDA_DIR/envs/gdf/share/jupyter/kernels/ && \
chmod -R go+rx $CONDA_DIR/envs/gdf/share/jupyter/kernels && \
rm -rf $HOME/.local && \
# fix-permissions $JULIA_PKGDIR $CONDA_DIR/share/jupyter
chown -R ${NB_USER}:users $JULIA_PKGDIR
USER root
RUN mv /home/jovyan/.julia /opt/julia
RUN sed s/'\/home\/jovyan'/'\/opt\/julia'/g /conda/envs/gdf/share/jupyter/kernels/julia-1.0/kernel.json > /kernel.json
RUN mv /kernel.json /conda/envs/gdf/share/jupyter/kernels/julia-1.0
RUN chown -R ${NB_USER}:users /opt/julia/.julia
USER $NB_UID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment