This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
100 lines (76 loc) · 2.87 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
# `python-base` sets up all our shared environment variables
FROM python:3.7.13-buster as python-base
# python
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.2.2 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# make poetry create the virtual environment in the project's root
# it gets named `.venv`
POETRY_VIRTUALENVS_IN_PROJECT=true \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
\
# paths
# this is where our requirements + virtual environment will live
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
ENV PATH="$VENV_PATH/bin:$POETRY_HOME/bin:$PATH"
# `builder-base` stage is used to build deps + create our virtual environment
FROM python-base as builder-base
RUN apt-get update && \
apt-get install --no-install-recommends -y \
git \
curl \
build-essential vim
RUN pip install --upgrade pip && \
pip install -U pip setuptools
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python3 -
# copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY pyproject.toml poetry.lock ./
# install deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --only main ; fi"
# the libraries below are required for demo projects
# Catboost can't be installed on ARM machines, so skip it if it fails
RUN pip install catboost==1.0.6; exit 0
RUN pip install \
torch==1.12.0 \
transformers==4.20.1 \
nlpaug==1.1.11
# ------------------------------------------------------------------------
# Add your python dependencies here, for example
# RUN pip install catboost transformers "tensorflow^2.9.1"
# ------------------------------------------------------------------------
FROM builder-base as proto-builder
WORKDIR $PYSETUP_PATH
# install dev dependencies needed to protobuf code generation
RUN poetry install --only main,dev
# copy makefile and proto to generate python sources
COPY ./giskard ./giskard
COPY ./ml-worker-proto ./ml-worker-proto
COPY ./scripts ./scripts
COPY ./Makefile ./
RUN make generate-proto
# `production` image used for runtime
FROM python-base as production
COPY --from=builder-base $VENV_PATH $VENV_PATH
COPY --from=proto-builder $PYSETUP_PATH/giskard $PYSETUP_PATH/giskard
WORKDIR $PYSETUP_PATH
ENV GSK_HOST=0.0.0.0
ENV PYTHONPATH=.
CMD ["python", "giskard/cli.py", "worker", "start", "-s"]
EXPOSE 50051