-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
87 lines (68 loc) · 2.71 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
## Base layer ##################################################################
# Use the watson-core base python image that comes in a variety of fun flavors
ARG BASE_UBI_IMAGE_TAG=9.3-1610
ARG PYTHON_TAG=py311
ARG PYTHON_VERSION=3.11
ARG SOURCE_DIR="fmperf"
FROM registry.access.redhat.com/ubi9/ubi:${BASE_UBI_IMAGE_TAG} as base
ARG PYTHON_VERSION=3.11
RUN dnf remove -y --disableplugin=subscription-manager \
subscription-manager \
# we install newer version of requests via pip
python${PYTHON_VERSION}-requests \
&& dnf install -y make git \
# to help with debugging
procps \
&& dnf clean all
# install python
RUN dnf install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-pip && \
dnf clean all && \
ln -fs /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 && \
ln -s /usr/bin/python${PYTHON_VERSION} /usr/local/bin/python && ln -s /usr/bin/pip${PYTHON_VERSION} /usr/local/bin/pip
# Set default working dir
WORKDIR /app
## Dev Dependencies Layer ######################################################
FROM base as dev_dependencies
COPY requirements.txt /app/requirements.txt
# speed up pip installs by caching a directory across builds
# https://pythonspeed.com/articles/docker-cache-pip-downloads/
RUN --mount=type=cache,target=/root/.cache \
true \
&& pip install -r /app/requirements.txt \
&& true
# Install kustomize
RUN curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash && \
mv kustomize /usr/local/bin
## Build Layer #################################################################
FROM dev_dependencies as build
ARG PYTHON_TAG
ARG SOURCE_DIR
# install TGIS protobufs
RUN git clone https://github.com/IBM/text-generation-inference.git && \
cd text-generation-inference && \
git checkout 9b4aea86846a5131bc6f672023cae5064bf9645c && \
cd integration_tests && \
make gen-client && \
pip install . --no-cache-dir
# Build the wheel
# Pull in source files
COPY ${SOURCE_DIR} /app/${SOURCE_DIR}
COPY setup.py /app/setup.py
RUN python setup.py bdist_wheel --python-tag ${PYTHON_TAG} clean --all
# And install it
RUN pip install --no-cache-dir /app/dist/*.whl
## Release Layer ###############################################################
FROM base as release
ARG SOURCE_DIR
# copy installed python dependencies
# Should include the wheel install + anything in requirements.txt
COPY --from=build /usr/local/ /usr/local/
# Create fmperf user
RUN adduser --uid 12345 --gid 0 fmperf
USER fmperf
WORKDIR /home/fmperf
# Set permissions for openshift
RUN chmod -R g+rwx /home/fmperf
ENV REQUESTS_DIR=/requests
# Sanity check: We can import the installed wheel
RUN python -c "import ${SOURCE_DIR}"