bumpver/docker_base.Dockerfile

66 lines
2.3 KiB
Text
Raw Normal View History

2018-11-04 21:34:53 +01:00
# Stages:
2018-12-06 14:21:21 +01:00
# root : Common image, both for the builder and for the final image.
2018-12-05 09:42:26 +01:00
# This contains only minimal dependencies required in both cases
# for miniconda and the makefile.
2018-12-06 14:21:21 +01:00
# env_builder: stage in which the conda envrionment is created
2018-12-05 09:42:26 +01:00
# and dependencies are installed
2018-12-06 14:21:21 +01:00
# base : the final image containing only the required environment files,
2018-12-05 09:42:26 +01:00
# and none of the infrastructure required to generate them.
2018-11-04 21:34:53 +01:00
2018-12-06 14:21:21 +01:00
FROM registry.gitlab.com/mbarkhau/bootstrapit/env_builder AS builder
2018-11-04 21:34:53 +01:00
RUN mkdir /root/.ssh/ && \
ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && \
ssh-keyscan registry.gitlab.com >> /root/.ssh/known_hosts
ARG SSH_PRIVATE_RSA_KEY
ENV ENV_SSH_PRIVATE_RSA_KEY=${SSH_PRIVATE_RSA_KEY}
# Write private key and generate public key
2018-11-09 19:22:17 +01:00
RUN if [[ "$ENV_SSH_PRIVATE_RSA_KEY" ]]; then \
2018-11-04 21:34:53 +01:00
echo -n "-----BEGIN RSA PRIVATE KEY-----" >> /root/.ssh/id_rsa && \
echo -n ${ENV_SSH_PRIVATE_RSA_KEY} \
| sed 's/-----BEGIN RSA PRIVATE KEY-----//' \
| sed 's/-----END RSA PRIVATE KEY-----//' \
| sed 's/ /\n/g' \
>> /root/.ssh/id_rsa && \
echo -n "-----END RSA PRIVATE KEY-----" >> /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/* && \
ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub; \
fi
ADD requirements/ requirements/
ADD scripts/ scripts/
ADD makefile.extra.make makefile.extra.make
ADD makefile.config.make makefile.config.make
ADD makefile makefile
RUN make install
2018-11-05 00:18:49 +01:00
RUN rm -f /root/.ssh/id_rsa
2018-11-04 21:34:53 +01:00
# Deleting pkgs implies that `conda install`
# will at have to pull all packages again.
RUN conda clean --all --yes
# Conda docs say that it is not safe to delete pkgs
# because there may be symbolic links, so we verify
# first that there are no such links.
RUN find -L /opt/conda/envs/ -type l | grep "/opt/conda/pkgs" || exit 0
# The conda install is not usable after this RUN command. Since
# we only need /opt/conda/envs/ anyway, this shouldn't be an issue.
RUN conda clean --all --yes && \
ls -d /opt/conda/* | grep -v envs | xargs rm -rf && \
find /opt/conda/ -name "*.exe" | xargs rm -rf && \
find /opt/conda/ -name "__pycache__" | xargs rm -rf && \
rm -rf /opt/conda/pkgs/
2018-12-06 14:21:21 +01:00
FROM registry.gitlab.com/mbarkhau/bootstrapit/root
2018-11-04 21:34:53 +01:00
2018-12-09 15:57:04 +01:00
RUN apt-get install --yes mercurial;
2018-11-04 21:34:53 +01:00
COPY --from=builder /opt/conda/ /opt/conda/
COPY --from=builder /vendor/ /vendor