I was able to solve the issue. In this template, PrivateSource.jl
is the main project and PrivateDep.jl
is a dependency. Both are cloned from a private repo. In this case I used gitlab.com .
The file id_rsa_gitlab
was generated by the following command (without password):
ssh-keygen -t rsa -b 4096 -C "felipenoris@gmail.com"
The following is the template Dockerfile.
FROM centos:7
MAINTAINER Felipe Noronha <felipenoris@gmail.com>
WORKDIR /root
RUN yum update -y && yum install -y epel-release && yum clean all
RUN yum update -y && yum install -y \
curl-devel \
libcurl \
libcurl-devel \
openssl \
openssl098e \
openssl-devel \
git \
wget \
&& yum clean all \
&& rm -rf /var/cache/yum/*
ENV PATH /usr/local/sbin:/usr/local/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/lib:/usr/local/lib64
# Julia - https://julialang.org/downloads/
ENV JULIA_VER_MAJ 1.2
ENV JULIA_VER_MIN .0
ENV JULIA_VER $JULIA_VER_MAJ$JULIA_VER_MIN
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/$JULIA_VER_MAJ/julia-$JULIA_VER-linux-x86_64.tar.gz \
&& mkdir /usr/local/julia \
&& tar xf julia-$JULIA_VER-linux-x86_64.tar.gz --directory /usr/local/julia --strip-components=1 \
&& ln -s /usr/local/julia/bin/julia /usr/local/bin/julia \
&& rm -f julia-$JULIA_VER-linux-x86_64.tar.gz
ENV TERM xterm
COPY id_rsa_gitlab /root/.ssh/id_rsa_gitlab
RUN chmod 600 /root/.ssh/id_rsa_gitlab
RUN eval $(ssh-agent -s) && \
ssh-add /root/.ssh/id_rsa_gitlab && \
ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && \
git clone --depth=1 --single-branch --branch master git@gitlab.com:felipenoris/PrivateSource.jl.git && \
julia --project=PrivateSource.jl -e 'using Pkg; Pkg.instantiate(); using PrivateSource'
CMD julia --project=PrivateSource.jl -e 'import PrivateSource; PrivateSource.greet()'
To build the image, I used a AWS server running centos7 with docker (ami-02e5c6d9065871fb7).
The following are the final steps of the build process (docker build -t julia-docker
):
Step 12/16 : ENV TERM xterm
---> Running in 587facc1249e
Removing intermediate container 587facc1249e
---> 72c5491f2e55
Step 13/16 : COPY id_rsa_gitlab /root/.ssh/id_rsa_gitlab
---> 30e5d67049c0
Step 14/16 : RUN chmod 600 /root/.ssh/id_rsa_gitlab
---> Running in 55e3608f8bc4
Removing intermediate container 55e3608f8bc4
---> db1f0943878a
Step 15/16 : RUN eval $(ssh-agent -s) && ssh-add /root/.ssh/id_rsa_gitlab && ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && git clone --depth=1 --single-branch --branch master git@gitlab.com:felipenoris/PrivateSource.jl.git && julia --project=PrivateSource.jl -e 'using Pkg; Pkg.instantiate(); using PrivateSource'
---> Running in 308d8b59e2f7
Agent pid 8
Identity added: /root/.ssh/id_rsa_gitlab (felipenoris@gmail.com)
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
# gitlab.com:22 SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
Cloning into 'PrivateSource.jl'...
Warning: Permanently added the ECDSA host key for IP address '35.231.145.151' to the list of known hosts.
Cloning git-repo `git@gitlab.com:felipenoris/PrivateDep.jl.git`
Updating git-repo `git@gitlab.com:felipenoris/PrivateDep.jl.git`
Removing intermediate container 308d8b59e2f7
---> c5d5ea9adc12
Step 16/16 : CMD julia --project=PrivateSource.jl -e 'import PrivateSource; PrivateSource.greet()'
---> Running in 2b90aa2372bd
Removing intermediate container 2b90aa2372bd
---> a63915d18507
Successfully built a63915d18507
Successfully tagged julia-docker:latest