-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile.hpo
68 lines (58 loc) · 2.46 KB
/
Dockerfile.hpo
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
#
# Copyright (c) 2022, 2022 Red Hat, IBM Corporation and others.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##########################################################
# Runtime Docker Image
##########################################################
# Use ubi-minimal as the base image
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
ARG HPO_VERSION
ARG USER=hpo
ARG UID=1001
ARG HPO_HOME=/home/$USER
WORKDIR $HPO_HOME/app
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
# make sure all files and modules are accessible by the user
PATH=$HPO_HOME/app/.local/bin:$HPO_HOME/app/bin:$PATH \
PYTHONUSERBASE=$HPO_HOME/app/.local
# Install packages needed for python to function correctly
RUN microdnf install -y python39 gcc-c++ python39-devel python39-pip\
&& microdnf update -y \
&& microdnf -y install shadow-utils \
# Setup the user for non-arbitrary UIDs with OpenShift
&& useradd -u ${UID} -s /usr/sbin/nologin default \
&& chown -R ${UID}:0 ${HPO_HOME}/app \
&& chmod -R g+rw ${HPO_HOME}/app \
&& microdnf -y remove shadow-utils \
&& microdnf clean all
# Switch to the non root user
USER ${UID}
# copy the requirements file to the app directory to install required modules
COPY --chown=${UID}:0 requirements.txt index.html experiment.html ${HPO_HOME}/app/
# Copy ML hyperparameter tuning code
COPY --chown=${UID}:0 src ${HPO_HOME}/app/src/
# Install required python packages
RUN python3 -m pip install --user --no-cache-dir --upgrade pip \
&& python3 -m pip install --user --no-cache-dir --requirement ${HPO_HOME}/app/requirements.txt
LABEL name="Kruize HPO" \
vendor="Red Hat" \
version=${HPO_VERSION} \
release=${HPO_VERSION} \
run="docker run --rm -it -p 8085:8085 <image_name:tag>" \
summary="Docker Image for HPO with ubi-minimal" \
description="For more information on this image please see https://github.com/kruize/hpo/blob/main/README.md"
EXPOSE 8085 50051
ENTRYPOINT python3 -u src/service.py