14
14
15
15
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 as build_base
16
16
17
- # https://blog.thesparktree.com/docker-multi-arch-github-actions#architecture-specific-dockerfile-instructions
18
- ARG TARGETARCH=amd64
17
+ # https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
18
+ # don't provide "default" values (e.g. 'ARG TARGETARCH=amd64') for non-buildx environments,
19
+ # see https://github.com/docker/buildx/issues/510
20
+ ARG TARGETOS
21
+ ARG TARGETARCH
19
22
20
23
ARG ETCD_VERSION=v3.5.4
21
24
22
25
LABEL image="build_base"
23
26
24
27
USER root
25
28
26
- RUN true \
27
- && microdnf --nodocs install java-17-openjdk-devel nss \
29
+ ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
30
+
31
+ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
32
+ microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
33
+ java-17-openjdk-devel \
34
+ nss \
28
35
&& microdnf update --nodocs \
29
- && microdnf clean all \
30
36
&& sed -i 's:security.provider.12=SunPKCS11:#security.provider.12=SunPKCS11:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
31
37
&& sed -i 's:#security.provider.1=SunPKCS11 ${java.home}/lib/security/nss.cfg:security.provider.12=SunPKCS11 ${java.home}/lib/security/nss.cfg:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
38
+ && java -version \
32
39
&& true
33
40
34
- RUN microdnf install wget tar gzip maven
35
-
36
- ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
41
+ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
42
+ microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
43
+ wget \
44
+ tar \
45
+ gzip \
46
+ maven \
47
+ && true
37
48
38
49
# Install etcd -- used for CI tests
39
- RUN wget -q https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${TARGETARCH}.tar.gz && \
40
- mkdir -p /usr/lib/etcd && \
41
- tar xzf etcd-*-linux-${TARGETARCH}.tar.gz -C /usr/lib/etcd --strip-components=1 --no-same-owner && \
42
- rm -rf etcd*.gz
43
-
44
50
ENV PATH="/usr/lib/etcd:$PATH"
51
+ RUN true \
52
+ && wget -q https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-${TARGETOS:-linux}-${TARGETARCH:-amd64}.tar.gz \
53
+ && mkdir -p /usr/lib/etcd \
54
+ && tar xzf etcd-*-${TARGETOS:-linux}-${TARGETARCH:-amd64}.tar.gz -C /usr/lib/etcd --strip-components=1 --no-same-owner \
55
+ && rm -rf etcd*.gz \
56
+ && etcd -version \
57
+ && true
45
58
46
59
# Copy in code
47
60
RUN mkdir /build
48
61
49
62
WORKDIR /build
50
63
64
+
51
65
# ##############################################################################
52
66
FROM build_base AS build
53
67
@@ -57,57 +71,71 @@ COPY / /build
57
71
58
72
ENV MAVEN_OPTS="-Dfile.encoding=UTF8"
59
73
60
- RUN mvn -B package -DskipTests=true --file pom.xml
74
+ RUN --mount=type=cache,target=/root/.m2 \
75
+ mvn -B package -DskipTests=true --file pom.xml
76
+
61
77
62
78
# ##############################################################################
63
- FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
79
+ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 AS runtime
64
80
65
- ARG imageVersion
66
- ARG buildId
67
- ARG commitSha
68
- ARG USER=2000
81
+ # TODO: FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15
69
82
70
- LABEL name="model-mesh" \
71
- vendor="KServe" \
72
- version="${imageVersion}" \
73
- summary="Core model-mesh sidecar image" \
74
- description="Model-mesh is a distributed LRU cache for serving runtime models" \
75
- release="${commitSha}"
76
-
83
+ ARG USER=2000
77
84
78
85
USER root
79
86
80
- RUN true \
81
- && microdnf --nodocs install java-17-openjdk-headless nss \
87
+ ENV JAVA_HOME=/usr/lib/jvm/jre-17-openjdk
88
+
89
+ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
90
+ microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
91
+ java-17-openjdk-headless \
92
+ nss \
82
93
&& microdnf update --nodocs \
83
- && microdnf clean all \
84
94
&& sed -i 's:security.provider.12=SunPKCS11:#security.provider.12=SunPKCS11:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
85
95
&& sed -i 's:#security.provider.1=SunPKCS11 ${java.home}/lib/security/nss.cfg:security.provider.12=SunPKCS11 ${java.home}/lib/security/nss.cfg:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
96
+ && java -version \
86
97
&& true
87
98
88
- ENV JAVA_HOME=/usr/lib/jvm/jre-17-openjdk
89
-
90
99
COPY --from=build /build/target/dockerhome/ /opt/kserve/mmesh/
91
100
92
101
# Make this the current directory when starting the container
93
102
WORKDIR /opt/kserve/mmesh
94
103
95
- RUN microdnf install shadow-utils hostname && \
104
+ RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
105
+ microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
106
+ shadow-utils \
107
+ hostname \
96
108
# Create app user
97
- useradd -c "Application User" -U -u ${USER} -m app && \
98
- chown -R app:0 /home/app && \
109
+ && useradd -c "Application User" -U -u ${USER} -m app \
110
+ && chown -R app:0 /home/app \
99
111
# Adjust permissions on /etc/passwd to be writable by group root.
100
112
# The user app is replaced by the assigned UID on OpenShift.
101
- chmod g+w /etc/passwd && \
113
+ && chmod g+w /etc/passwd \
102
114
# In newer Docker there is a --chown option for the COPY command
103
- ln -s /opt/kserve/mmesh /opt/kserve/tas && \
104
- mkdir -p log && \
105
- chown -R app:0 . && \
106
- chmod -R 771 . && chmod 775 *.sh *.py && \
107
- echo "${buildId}" > /opt/kserve/mmesh/build-version && \
108
- \
115
+ && ln -s /opt/kserve/mmesh /opt/kserve/tas \
116
+ && mkdir -p log \
117
+ && chown -R app:0 . \
118
+ && chmod -R 771 . \
119
+ && chmod 775 *.sh *.py \
109
120
# Disable java FIPS - see https://access.redhat.com/documentation/en-us/openjdk/17/html-single/configuring_openjdk_17_on_rhel_with_fips/index#config-fips-in-openjdk
110
- sed -i 's/security.useSystemPropertiesFile=true/security.useSystemPropertiesFile=false/g' $JAVA_HOME/conf/security/java.security
121
+ && sed -i 's/security.useSystemPropertiesFile=true/security.useSystemPropertiesFile=false/g' $JAVA_HOME/conf/security/java.security \
122
+ && true
123
+
124
+ # wait to create commit-specific LABEL until end of the build to not unnecessarily
125
+ # invalidate the cached image layers
126
+ ARG imageVersion
127
+ ARG buildId
128
+ ARG commitSha
129
+
130
+ RUN echo "${buildId}" > /opt/kserve/mmesh/build-version
131
+
132
+ LABEL name="model-mesh" \
133
+ vendor="KServe" \
134
+ version="${imageVersion}" \
135
+ summary="Core model-mesh sidecar image" \
136
+ description="Model-mesh is a distributed LRU cache for serving runtime models" \
137
+ release="${commitSha}" \
138
+
111
139
112
140
EXPOSE 8080
113
141
0 commit comments