-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_base.Dockerfile
More file actions
73 lines (58 loc) · 2.6 KB
/
docker_base.Dockerfile
File metadata and controls
73 lines (58 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Stages:
# root : Common image, both for the builder and for the final image.
# This contains only minimal dependencies required in both cases
# for miniconda and the makefile.
# env_builder: stage in which the conda envrionment is created
# and dependencies are installed
# base : the final image containing only the required environment files,
# and none of the infrastructure required to generate them.
FROM registry.gitlab.com/mbarkhau/bootstrapit/env_builder AS builder
# gcc required for cmarkgfm on python3.8
# https://github.com/theacodes/cmarkgfm/issues/22
RUN apt-get update
RUN apt-get install -y gcc
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
RUN if ! test -z "${ENV_SSH_PRIVATE_RSA_KEY}"; then \
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.bootstrapit.make makefile.bootstrapit.make
ADD makefile makefile
# install envs (relatively stable)
ADD requirements/conda.txt requirements/conda.txt
RUN make build/envs.txt
# install python package dependencies (change more often)
ADD requirements/ requirements/
RUN make conda
RUN rm -f /root/.ssh/id_rsa
# Deleting pkgs implies that `conda install`
# will 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/
FROM registry.gitlab.com/mbarkhau/bootstrapit/root
COPY --from=builder /opt/conda/ /opt/conda/
COPY --from=builder /vendor/ /vendor