diff --git a/Dockerfile b/Dockerfile index 8d0b3c13..40c02849 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ # Stage 1: Create the developer image for the BUILDPLATFORM only ############################################################################### ARG GOLANG_VERSION=1.21 +ARG BUILD_BASE=develop FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION AS develop ARG PROTOC_VERSION=21.5 @@ -77,6 +78,8 @@ RUN set -eux; \ WORKDIR /opt/app COPY go.mod go.sum ./ +# Download dependencies before copying the source so they will be cached +RUN go mod download # Install go protoc plugins # no required module provides package google.golang.org/grpc/cmd/protoc-gen-go-grpc @@ -98,8 +101,6 @@ RUN git init && \ git config --global --add safe.directory "*" && \ rm -rf .git -# Download dependencies before copying the source so they will be cached -RUN go mod download # the ubi/go-toolset image doesn't define ENTRYPOINT or CMD, but we need it to run 'make develop' CMD /bin/bash @@ -108,10 +109,18 @@ CMD /bin/bash ############################################################################### # Stage 2: Run the go build with BUILDPLATFORM's native go compiler ############################################################################### -FROM --platform=$BUILDPLATFORM develop AS build +FROM --platform=$BUILDPLATFORM $BUILD_BASE AS build LABEL image="build" +USER root + +# needed for konflux as the previous stage is not used +WORKDIR /opt/app +COPY go.mod go.sum ./ +# Download dependencies before copying the source so they will be cached +RUN go mod download + # Copy the source COPY . ./ @@ -146,7 +155,7 @@ USER root # install python to convert keras to tf # NOTE: tensorflow not supported on PowerPC (ppc64le) or System Z (s390x) https://github.com/tensorflow/tensorflow/issues/46181 RUN --mount=type=cache,target=/root/.cache/microdnf:rw \ - microdnf install --setopt=cachedir=/root/.cache/microdnf \ + microdnf install --setopt=cachedir=/root/.cache/microdnf --setopt=ubi-8-appstream-rpms.module_hotfixes=1 \ gcc \ gcc-c++ \ python38-devel \ @@ -157,9 +166,9 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \ # need to upgrade pip and install wheel before installing grpcio, before installing tensorflow on aarch64 # use caching to speed up multi-platform builds +COPY requirements.txt requirements.txt ENV PIP_CACHE_DIR=/root/.cache/pip RUN --mount=type=cache,target=/root/.cache/pip \ - pip install --upgrade pip && \ pip install wheel && \ pip install grpcio && \ # pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \ @@ -167,7 +176,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # for arm yet. pip install h5py==3.10.0 && \ pip install tensorflow - +RUN rm -rfv requirements.txt USER ${USER} # Add modelmesh version diff --git a/README.md b/README.md index af056d7d..a6519625 100644 --- a/README.md +++ b/README.md @@ -194,3 +194,33 @@ modelmesh-controller-64f5c8d6d6-k6rzc kserve/modelmesh-controller:lat modelmesh-serving-mlserver-1.x-84884c6849-s8dw6 kserve/rest-proxy:latest, seldonio/mlserver:1.3.2, your-docker-userid/modelmesh-runtime-adapter:dev, kserve/modelmesh:latest modelmesh-serving-mlserver-1.x-84884c6849-xpdw4 kserve/rest-proxy:latest, seldonio/mlserver:1.3.2, your-docker-userid/modelmesh-runtime-adapter:dev, kserve/modelmesh:latest ``` + +# Konflux build system Files + +This directory holds the requirements.txt file use in the Konflux builds to pre-fetch the required packages. + +Here are two files that we need to keep: + +- **requirements.txt**: is the result of the `pip freeze` command (see example below). + +## How to update the requirements.txt file + +Once the final container is built, you can access it: + +```bash +podman run sh -c 'pip freeze' +``` + +Note, for `tensorflow-io-gcs-filesystem` it must be pinned to **0.34.0** manually after generating the `requirements.txt` file.` + +Then commit the changes and push. + +# Konflux configuration + +Build configuration, it requires the build be configured as follows: + +```yaml +- name: prefetch-input + value: | + [{"type": "gomod"}, {"type": "rpm"}, {"type": "pip", "path": ".", "requirements_files": ["requirements.txt"], "allow_binary": "true"}] +``` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..f851cb32 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,45 @@ +absl-py==2.1.0 +astunparse==1.6.3 +cachetools==5.5.0 +certifi==2024.8.30 +charset-normalizer==3.3.2 +flatbuffers==24.3.25 +gast==0.4.0 +google-auth==2.34.0 +google-auth-oauthlib==1.0.0 +google-pasta==0.2.0 +grpcio==1.66.1 +# pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \ +# if not version is set, it will install the 3.11.0 version which, seems that does not have the h5py dependencies \ +# for arm yet. +h5py==3.10.0 +idna==3.8 +importlib-metadata==8.4.0 +keras==2.13.1 +libclang==18.1.1 +Markdown==3.7 +MarkupSafe==2.1.5 +numpy==1.24.3 +oauthlib==3.2.2 +opt-einsum==3.3.0 +packaging==24.1 +protobuf==4.25.4 +pyasn1==0.6.0 +pyasn1-modules==0.4.0 +requests==2.32.3 +requests-oauthlib==2.0.0 +rsa==4.9 +six==1.16.0 +tensorboard==2.13.0 +tensorboard-data-server==0.7.2 +tensorflow==2.13.1 +tensorflow-estimator==2.13.0 +# Note, for `tensorflow-io-gcs-filesystem` it must be pinned to 0.34.0 manually after generating the `requirements.txt` file. +tensorflow-io-gcs-filesystem==0.34.0 +termcolor==2.4.0 +typing-extensions==4.5.0 +urllib3==2.2.2 +werkzeug==3.0.4 +wheel==0.44.0 +wrapt==1.16.0 +zipp==3.20.1 \ No newline at end of file