1616# Stage 1: Create the developer image for the BUILDPLATFORM only
1717# ##############################################################################
1818ARG GOLANG_VERSION=1.21
19+ ARG BUILD_BASE=develop
1920FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION AS develop
2021
2122ARG PROTOC_VERSION=21.5
@@ -77,6 +78,8 @@ RUN set -eux; \
7778WORKDIR /opt/app
7879
7980COPY go.mod go.sum ./
81+ # Download dependencies before copying the source so they will be cached
82+ RUN go mod download
8083
8184# Install go protoc plugins
8285# no required module provides package google.golang.org/grpc/cmd/protoc-gen-go-grpc
@@ -98,8 +101,6 @@ RUN git init && \
98101 git config --global --add safe.directory "*" && \
99102 rm -rf .git
100103
101- # Download dependencies before copying the source so they will be cached
102- RUN go mod download
103104
104105# the ubi/go-toolset image doesn't define ENTRYPOINT or CMD, but we need it to run 'make develop'
105106CMD /bin/bash
@@ -108,10 +109,18 @@ CMD /bin/bash
108109# ##############################################################################
109110# Stage 2: Run the go build with BUILDPLATFORM's native go compiler
110111# ##############################################################################
111- FROM --platform=$BUILDPLATFORM develop AS build
112+ FROM --platform=$BUILDPLATFORM $BUILD_BASE AS build
112113
113114LABEL image="build"
114115
116+ USER root
117+
118+ # needed for konflux as the previous stage is not used
119+ WORKDIR /opt/app
120+ COPY go.mod go.sum ./
121+ # Download dependencies before copying the source so they will be cached
122+ RUN go mod download
123+
115124# Copy the source
116125COPY . ./
117126
@@ -146,7 +155,7 @@ USER root
146155# install python to convert keras to tf
147156# NOTE: tensorflow not supported on PowerPC (ppc64le) or System Z (s390x) https://github.com/tensorflow/tensorflow/issues/46181
148157RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
149- microdnf install --setopt=cachedir=/root/.cache/microdnf \
158+ microdnf install --setopt=cachedir=/root/.cache/microdnf --setopt=ubi-8-appstream-rpms.module_hotfixes=1 \
150159 gcc \
151160 gcc-c++ \
152161 python38-devel \
@@ -157,17 +166,11 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
157166
158167# need to upgrade pip and install wheel before installing grpcio, before installing tensorflow on aarch64
159168# use caching to speed up multi-platform builds
169+ COPY requirements.txt requirements.txt
160170ENV PIP_CACHE_DIR=/root/.cache/pip
161171RUN --mount=type=cache,target=/root/.cache/pip \
162- pip install --upgrade pip && \
163- pip install wheel && \
164- pip install grpcio && \
165- # pin to 3.10.0 to avoid error: libhdf5.so: cannot open shared object file: No such file or directory \
166- # if not version is set, it will install the 3.11.0 version which, seems that does not have the h5py dependencies \
167- # for arm yet.
168- pip install h5py==3.10.0 && \
169- pip install tensorflow
170-
172+ pip install -r requirements.txt
173+ RUN rm -rfv requirements.txt
171174USER ${USER}
172175
173176# Add modelmesh version
0 commit comments