forked from equinor/gordo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-GordoDeploy
80 lines (59 loc) · 2.7 KB
/
Dockerfile-GordoDeploy
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
# Installs workflow-generator, kubectl and argo. Runs workflow-generator on the machine-config
# stored in the environment variable MACHINE_CONFIG, or if that is empty, the file
# /code/config.yml, which is then the callers responsibility to mount in.
FROM python:3.7.5 as builder
# Copy source code
COPY . /code
# Copy .git to deduce version number
COPY .git /code/
WORKDIR /code
RUN rm -rf /code/dist \
&& python setup.py sdist \
&& mv /code/dist/$(ls /code/dist | head -1) /code/dist/gordo-packed.tar.gz
# Extract a few big dependencies which docker will cache even when other dependencies change
RUN cat /code/requirements.txt | grep tensorflow== > /code/prereq.txt \
&& cat /code/requirements.txt | grep pyarrow== >> /code/prereq.txt \
&& cat /code/requirements.txt | grep scipy== >> /code/prereq.txt \
&& cat /code/requirements.txt | grep catboost== >> /code/prereq.txt
ARG HTTPS_PROXY
ARG KUBECTL_VERSION="v1.14.8"
ARG ARGO_VERSION="v2.4.2"
#donwload & install kubectl
RUN curl -sSL -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl &&\
chmod +x /usr/local/bin/kubectl
#download & install argo
RUN curl -sSL -o /usr/local/bin/argo https://github.com/argoproj/argo/releases/download/$ARGO_VERSION/argo-linux-amd64 &&\
chmod +x /usr/local/bin/argo
FROM python:3.7.5-slim-stretch
# Nonroot user for running CMD
RUN groupadd -g 999 gordo && \
useradd -r -u 999 -g gordo gordo
ENV HOME "/home/gordo"
ENV PATH "${HOME}/.local/bin:${PATH}"
# Install requirements and gordo packaged in intermediate image 'python setup.py sdist'
COPY --from=builder /code/prereq.txt .
RUN pip install --no-deps -r prereq.txt --no-cache-dir
COPY requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir
# Install gordo, packaged from earlier 'python setup.py sdist'
COPY --from=builder /code/dist/gordo-packed.tar.gz .
RUN pip install gordo-packed.tar.gz
RUN apt-get update && apt-get install -y \
curl \
jq \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=builder /usr/local/bin/argo /usr/local/bin/argo
COPY ./run_workflow_and_argo.sh ${HOME}/run_workflow_and_argo.sh
# Baking in example configs for running tests, as docker.client.containers.run
# bind doesn't seem to work correctly for non-root users
# volumes={repo_dir: {"bind": "/home/gordo", "mode": "ro"}},
COPY ./examples ${HOME}/examples
COPY ./resources ${HOME}/resources
# Make gordo own all in its home
RUN chown -R gordo:gordo ${HOME}
# Switch user
USER gordo
# Run things from gordo's home to have write access when needed (e.g. Catboost tmp files)
WORKDIR ${HOME}
CMD ["bash", "./run_workflow_and_argo.sh"]