forked from equinor/gordo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-ModelServer
49 lines (35 loc) · 1.42 KB
/
Dockerfile-ModelServer
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
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
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 separately for improved docker caching
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
# 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 ["gordo", "run-server"]