Skip to content

Commit

Permalink
Support plots in docker
Browse files Browse the repository at this point in the history
GR plots couldn't display with the ubuntu images, probably due to
missing packages. To support them, followed the instructions in
http://gr-framework.org/tutorials/docker.html

- Image based on fedora
- Julia built from source, takes a long time
- docker --ipc=host opens a potential security hole. Based on
    osrf/docker_images#21
  • Loading branch information
Oblynx committed May 4, 2018
1 parent ea6ee25 commit bd8efa5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 50 deletions.
90 changes: 40 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,60 +1,48 @@
FROM ubuntu:latest
FROM fedora:latest

### Install Julia ###
RUN dnf install -y \
cmake \
curl \
findutils \
gcc \
gcc-c++ \
gcc-gfortran \
git \
m4 \
make \
patch \
perl \
pkgconfig \
python \
wget \
which \
xz \
openssl \
bzip2 \
&& dnf clean all

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
apt-utils
RUN apt-get install -y gpg
ENV JULIA_PATH /usr/local/julia

# https://julialang.org/juliareleases.asc
# Julia (Binary signing key) <[email protected]>
ENV JULIA_GPG 3673DF529D9049477F76B37566E3C7DC03D6E495

# https://julialang.org/downloads/
ENV JULIA_VERSION 0.6.2

RUN set -ex; \
\
# https://julialang.org/downloads/#julia-command-line-version
# https://julialang-s3.julialang.org/bin/checksums/julia-0.6.2.sha256
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) tarArch='x86_64'; dirArch='x64'; sha256='dc6ec0b13551ce78083a5849268b20684421d46a7ec46b17ec1fab88a5078580' ;; \
armhf) tarArch='armv7l'; dirArch='armv7l'; sha256='1c37aa7cba7372d949a91de53f53609b1b0c9cbeca436eb2fe7f5083d9f62c82' ;; \
arm64) tarArch='aarch64'; dirArch='aarch64'; sha256='19a8945bdb3d35b7bf0432a9e066fb7831d11d1c1acfe56abd8fcabbf1ebddb4' ;; \
i386) tarArch='i686'; dirArch='x86'; sha256='099e39ad958aff2ef63841a812f5df62f8553aafc6dd33abb0eb0c67142c5e49' ;; \
*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding Julia binary release"; exit 1 ;; \
esac; \
\
curl -fL -o julia.tar.gz "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"; \
curl -fL -o julia.tar.gz.asc "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz.asc"; \
\
echo "${sha256} *julia.tar.gz" | sha256sum -c -; \
\
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$JULIA_GPG"; \
gpg --batch --verify julia.tar.gz.asc julia.tar.gz; \
rm -rf "$GNUPGHOME" julia.tar.gz.asc; \
\
mkdir "$JULIA_PATH"; \
tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1; \
rm julia.tar.gz

RUN cd /tmp && \
git clone https://github.com/JuliaLang/julia.git && \
cd /tmp/julia && \
git checkout release-0.6 && \
echo 'MARCH=native' >> Make.user && \
echo "prefix=$JULIA_PATH" >> Make.user && \
mkdir "$JULIA_PATH";
RUN cd /tmp/julia && \
make -j8 && \
make install && \
cd /tmp && \
rm -rf julia

ENV PATH $JULIA_PATH/bin:$PATH

CMD ["julia"]


### custom ###

RUN apt-get update && apt-get -y install apt-utils
RUN apt-get -y install sudo
RUN dnf update -y && dnf install -y sudo

RUN export uid=1000 gid=1000 && \
mkdir -p "/home/developer" && \
Expand All @@ -70,10 +58,12 @@ ENV HOME /home/developer
COPY ./src/env_setup.jl /htm.jl/src/
RUN julia -e 'include("/htm.jl/src/env_setup.jl")'

# Additional julia-related system packages
RUN sudo apt-get -y install \
libxt6 libxrender1 libgl1-mesa-glx \
x11-apps mesa-utils libqt5widgets5 python-qt4-dev libglfw3-dev libwxgtk3.0-dev libzmq3-dev
# Setup GR
RUN sudo dnf install -y \
python-matplotlib ipython \
texlive-collection-latex PyQt4-devel wxGTK-devel ghostscript-devel \
glfw-devel zeromq-devel mupdf-devel jbig2dec-devel openjpeg2-devel \
libjpeg-turbo-devel

WORKDIR "/htm.jl/src"
CMD ["julia"]
1 change: 1 addition & 0 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docker build -t "htm.jl" .
docker run --rm -it --name "htm.jl" \
-v "$project_root/src":"/htm.jl/src" \
--device=/dev/dri/renderD128 \
--ipc host \
-e DISPLAY \
--net=host \
htm.jl ${1:+"$1"}
Expand Down

0 comments on commit bd8efa5

Please sign in to comment.