Skip to content

Commit b63cb9b

Browse files
committed
Adjust Dockerfile to be more friendly with openshift-ci
In openshift-ci, only static values can be passed when building a Dockerfile. However, the `imageVersion`, `buildId` and `commitSha` are required to be generated when doing the build (are dynamic); e.g: ``` GIT_COMMIT=$(git rev-parse HEAD) BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5) IMAGE_TAG_VERSION=0.11.0-alpha IMAGE_TAG=${IMAGE_TAG_VERSION}-$(git branch --show-current)_${BUILD_ID} podman build \ --build-arg imageVersion=${IMAGE_TAG} \ --build-arg buildId=${BUILD_ID} \ --build-arg commitSha=${GIT_COMMIT} . ``` The most important argument is `buildId` to let ModelMesh identify the build date of itself. This changes the Dockerfile to resolve the `buildId` in the builder stage. The `imageVersion` and `commitSha` arguments are lost, under the rationale that these are not essential for ModelMesh to work correctly. Signed-off-by: Edgar Hernández <[email protected]>
1 parent 7f33789 commit b63cb9b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.cache
66
.dockerignore
77
.env
8-
.git
98
.github
109
.gitignore
1110
.idea

Dockerfile

+13-6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
4444
tar \
4545
gzip \
4646
maven \
47+
git \
4748
&& true
4849

4950
# Install etcd -- used for CI tests
@@ -74,6 +75,11 @@ ENV MAVEN_OPTS="-Dfile.encoding=UTF8"
7475
RUN --mount=type=cache,target=/root/.m2 \
7576
mvn -B package -DskipTests=true --file pom.xml
7677

78+
# Assume that source code comes from a Git repository
79+
RUN echo "$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)" > target/dockerhome/build-version && \
80+
echo "$(git rev-parse HEAD)" > target/dockerhome/release && \
81+
echo "$(git branch --show-current|sed 's/^release-//g')-$(git branch --show-current)_$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)" > target/dockerhome/version
82+
7783

7884
###############################################################################
7985
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 AS runtime
@@ -124,18 +130,19 @@ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
124130

125131
# wait to create commit-specific LABEL until end of the build to not unnecessarily
126132
# invalidate the cached image layers
127-
ARG imageVersion
128-
ARG buildId
129-
ARG commitSha
133+
# ARG imageVersion
134+
# ARG buildId
135+
# ARG commitSha
130136

131-
RUN echo "${buildId}" > /opt/kserve/mmesh/build-version
137+
# Generated at build stage
138+
# RUN echo "${buildId}" > /opt/kserve/mmesh/build-version
132139

133140
LABEL name="model-mesh" \
134141
vendor="KServe" \
135-
version="${imageVersion}" \
142+
# version="${imageVersion}" \
136143
summary="Core model-mesh sidecar image" \
137144
description="Model-mesh is a distributed LRU cache for serving runtime models" \
138-
release="${commitSha}" \
145+
# release="${commitSha}" \
139146
maintainer="[email protected]"
140147

141148
EXPOSE 8080

0 commit comments

Comments
 (0)