-
Notifications
You must be signed in to change notification settings - Fork 341
/
Dockerfile
132 lines (116 loc) · 4.44 KB
/
Dockerfile
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
ARG BASE_IMAGE=ubuntu:20.04
FROM ${BASE_IMAGE}
ARG BASE_IMAGE
LABEL maintainer="CML <[email protected]>"
# CONFIGURE NON-INTERACTIVE APT
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90assumeyes
# CONFIGURE SHELL
SHELL ["/bin/bash", "-c"]
# FIX NVIDIA APT GPG KEYS (https://github.com/NVIDIA/cuda-repo-management/issues/1#issuecomment-1111490201) 🤬
RUN grep nvidia <<< ${BASE_IMAGE} \
&& for list in cuda nvidia-ml; do mv /etc/apt/sources.list.d/$list.list{,.backup}; done \
&& apt-get update \
&& apt-get install --yes gpg \
&& apt-key del 7fa2af80 \
&& apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/7fa2af80.pub \
&& apt-get purge --yes gpg \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/* \
&& for list in cuda nvidia-ml; do mv /etc/apt/sources.list.d/$list.list{.backup,}; done \
|| true
# INSTALL CORE DEPENDENCIES
RUN apt-get update \
&& apt-get install --no-install-recommends \
build-essential \
apt-utils \
apt-transport-https \
ca-certificates \
iputils-ping \
software-properties-common \
pkg-config \
curl \
wget \
unzip \
gpg-agent \
sudo \
tzdata \
locales \
&& locale-gen en_US.UTF-8 \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/*
# CONFIGURE LOCALE
ENV LANG="en_US.UTF-8"
ENV LANGUAGE="en_US:en"
ENV LC_ALL="en_US.UTF-8"
# INSTALL NODE, GIT & GO
RUN add-apt-repository ppa:git-core/ppa --yes \
&& add-apt-repository ppa:longsleep/golang-backports --yes \
&& curl --location https://deb.nodesource.com/setup_16.x | bash \
&& apt-get update \
&& apt-get install --yes git golang-go nodejs \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/*
# INSTALL TERRAFORM
RUN curl --remote-name --location https://releases.hashicorp.com/terraform/1.9.8/terraform_1.9.8_linux_amd64.zip \
&& unzip terraform_1.9.8_linux_amd64.zip \
&& mv terraform /usr/bin \
&& rm LICENSE.txt terraform_1.9.8_linux_amd64.zip \
&& terraform version # make sure it works
# INSTALL LEO
RUN curl --location https://github.com/iterative/terraform-provider-iterative/releases/latest/download/leo_linux_amd64 \
--output /usr/bin/leo \
&& chmod +x /usr/bin/leo
# INSTALL PYTHON
ARG PYTHON_VERSION=3
RUN add-apt-repository universe --yes \
&& apt-get update \
&& PYTHON_SUFFIX="$(sed --expression='s/3.*/3/g' --expression='s/2.*//g' <<< "${PYTHON_VERSION}")" \
&& apt-get install --yes --no-install-recommends python${PYTHON_VERSION} python${PYTHON_SUFFIX}{-pip,-setuptools,-dev} \
&& update-alternatives --install /usr/bin/python python${PYTHON_VERSION} $(which python${PYTHON_VERSION}) 10 \
&& python -m pip install pip --upgrade \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/*
# INSTALL DVC
ARG DVC_VERSION=3
RUN cd /etc/apt/sources.list.d \
&& wget https://dvc.org/deb/dvc.list \
&& apt-get update \
&& apt-get install --yes "dvc=${DVC_VERSION}.*" \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/*
# INSTALL CML
ARG CML_VERSION=0
RUN npm config set user 0 \
&& npm install --global "@dvcorg/cml@${CML_VERSION}"
# INSTALL VEGA
RUN add-apt-repository universe --yes \
&& apt-get update \
&& apt-get install --yes \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
libfontconfig-dev \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/* \
&& npm config set user 0 \
&& npm install --global canvas@2 vega@5 vega-cli@5 [email protected]
# CONFIGURE RUNNER PATH
ENV CML_RUNNER_PATH=/home/runner
RUN mkdir ${CML_RUNNER_PATH}
WORKDIR ${CML_RUNNER_PATH}
# SET SPECIFIC ENVIRONMENT VARIABLES
ENV IN_DOCKER=1
ENV RUNNER_ALLOW_RUNASROOT=1
# Environment variable used by cml to detect it's been installed using the docker image.
ENV _CML_CONTAINER_IMAGE=true
# DEFINE ENTRY POINT AND COMMAND
# Smart entrypoint understands commands like `bash` or `/bin/sh` but defaults to `cml`;
# also works for GitLab CI/CD
# https://gitlab.com/gitlab-org/gitlab-runner/-/blob/4c42e96/shells/bash.go#L18-37
# https://gitlab.com/gitlab-org/gitlab-runner/-/blob/4c42e96/shells/bash.go#L288
ENTRYPOINT ["/bin/bash", "-c", "echo \"$0\" | grep -qE '^(pr|publish|runner|send-(comment|github-check)|tensorboard-dev|--?\\w.*)$' && exec cml \"$0\" \"$@\" || exec \"$0\" \"$@\""]
CMD ["--help"]