Skip to content

Commit f7ddbd9

Browse files
authored
Merge pull request opendatahub-io#18 from Jooho/20230605_sync_main
[Sync] kserve/modelmesh-v0.11.0-rc0 to main branch
2 parents e6d55e1 + 021eaec commit f7ddbd9

File tree

14 files changed

+573
-784
lines changed

14 files changed

+573
-784
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1+
**/*.class
2+
*.jar
3+
*.md
4+
.DS_Store
5+
.cache
6+
.dockerignore
17
.env
8+
.git
9+
.github
10+
.gitignore
11+
.idea
12+
.vscode
13+
default.etcd
14+
target
15+
temp
Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
name: Build and Push
1+
name: Build
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- "release-[0-9].[0-9]+"
8+
paths-ignore:
9+
- "**.md"
410
push:
5-
branches: [ main ]
11+
branches:
12+
- main
13+
- "release-[0-9].[0-9]+"
614
tags:
7-
- v*
8-
pull_request:
15+
- "v*"
16+
paths-ignore:
17+
- "**.md"
18+
19+
env:
20+
IMAGE_NAME: "kserve/modelmesh"
921

1022
jobs:
1123
test:
1224
runs-on: ubuntu-latest
1325
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up JDK 17
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Set up Java 17
1630
uses: actions/[email protected]
1731
with:
1832
java-version: '17'
1933
distribution: 'temurin'
34+
2035
- name: Install etcd
2136
run: sudo ./.github/install-etcd.sh
22-
- name: Build with Maven
37+
38+
- name: Build and Test with Maven
2339
run: mvn -B package --file pom.xml
2440

2541
build:
2642
needs: test
2743
runs-on: ubuntu-latest
28-
29-
env:
30-
IMAGE_NAME: kserve/modelmesh
31-
3244
steps:
33-
- uses: actions/checkout@v2
45+
- name: Checkout
46+
uses: actions/checkout@v3
3447

3548
- name: Setup QEMU
3649
uses: docker/setup-qemu-action@v2
@@ -45,32 +58,38 @@ jobs:
4558
username: ${{ secrets.DOCKER_USER }}
4659
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
4760

48-
- name: Export version variables
61+
- name: Export docker build args
4962
run: |
5063
GIT_COMMIT=$(git rev-parse HEAD)
5164
BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)
5265
5366
# Strip git ref prefix from version
5467
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
5568
69+
# Generate PR tag from github.ref == "refs/pull/123/merge"
70+
[ "$VERSION" == "merge" ] && VERSION=$(echo "${{ github.ref }}" | sed -e 's,refs/pull/\(.*\)/merge,pr-\1,')
71+
5672
# Use Docker `latest` tag convention
5773
[ "$VERSION" == "main" ] && VERSION=latest
5874
5975
echo "GIT_COMMIT=$GIT_COMMIT" >> $GITHUB_ENV
60-
echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV
61-
echo "VERSION=$VERSION" >> $GITHUB_ENV
76+
echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV
77+
echo "VERSION=$VERSION" >> $GITHUB_ENV
6278
63-
- name: Build and push
64-
uses: docker/build-push-action@v3
79+
# print env vars for debugging
80+
cat "$GITHUB_ENV"
81+
82+
- name: Build and push runtime image
83+
uses: docker/build-push-action@v4
6584
with:
6685
# for linux/s390x, maven errors due to missing io.grpc:protoc-gen-grpc-java:exe:linux-s390_64:1.51.1
6786
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le
68-
pull: true
69-
cache-from: type=gha
70-
cache-to: type=gha,mode=max
87+
target: runtime
7188
push: ${{ github.event_name == 'push' }}
7289
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
7390
build-args: |
7491
imageVersion=${{ env.VERSION }}
7592
buildId=${{ env.BUILD_ID }}
7693
commitSha=${{ env.GIT_COMMIT }}
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,54 @@
1414

1515
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 as build_base
1616

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
1922

2023
ARG ETCD_VERSION=v3.5.4
2124

2225
LABEL image="build_base"
2326

2427
USER root
2528

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 \
2835
&& microdnf update --nodocs \
29-
&& microdnf clean all \
3036
&& sed -i 's:security.provider.12=SunPKCS11:#security.provider.12=SunPKCS11:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
3137
&& 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 \
3239
&& true
3340

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
3748

3849
# 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-
4450
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
4558

4659
# Copy in code
4760
RUN mkdir /build
4861

4962
WORKDIR /build
5063

64+
5165
###############################################################################
5266
FROM build_base AS build
5367

@@ -57,58 +71,72 @@ COPY / /build
5771

5872
ENV MAVEN_OPTS="-Dfile.encoding=UTF8"
5973

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+
6177

6278
###############################################################################
63-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
79+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 AS runtime
6480

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
6982

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
7784

7885
USER root
7986

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 \
8293
&& microdnf update --nodocs \
83-
&& microdnf clean all \
8494
&& sed -i 's:security.provider.12=SunPKCS11:#security.provider.12=SunPKCS11:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
8595
&& 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 \
8697
&& true
8798

88-
ENV JAVA_HOME=/usr/lib/jvm/jre-17-openjdk
89-
9099
COPY --from=build /build/target/dockerhome/ /opt/kserve/mmesh/
91100
COPY version /etc/modelmesh-version
92101

93102
# Make this the current directory when starting the container
94103
WORKDIR /opt/kserve/mmesh
95104

96-
RUN microdnf install shadow-utils hostname && \
105+
RUN --mount=type=cache,target=/root/.cache/microdnf:rw \
106+
microdnf --setopt=cachedir=/root/.cache/microdnf --nodocs install \
107+
shadow-utils \
108+
hostname \
97109
# Create app user
98-
useradd -c "Application User" -U -u ${USER} -m app && \
99-
chown -R app:0 /home/app && \
110+
&& useradd -c "Application User" -U -u ${USER} -m app \
111+
&& chown -R app:0 /home/app \
100112
# Adjust permissions on /etc/passwd to be writable by group root.
101113
# The user app is replaced by the assigned UID on OpenShift.
102-
chmod g+w /etc/passwd && \
114+
&& chmod g+w /etc/passwd \
103115
# In newer Docker there is a --chown option for the COPY command
104-
ln -s /opt/kserve/mmesh /opt/kserve/tas && \
105-
mkdir -p log && \
106-
chown -R app:0 . && \
107-
chmod -R 771 . && chmod 775 *.sh *.py && \
108-
echo "${buildId}" > /opt/kserve/mmesh/build-version && \
109-
\
116+
&& ln -s /opt/kserve/mmesh /opt/kserve/tas \
117+
&& mkdir -p log \
118+
&& chown -R app:0 . \
119+
&& chmod -R 771 . \
120+
&& chmod 775 *.sh *.py \
110121
# 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
111-
sed -i 's/security.useSystemPropertiesFile=true/security.useSystemPropertiesFile=false/g' $JAVA_HOME/conf/security/java.security
122+
&& sed -i 's/security.useSystemPropertiesFile=true/security.useSystemPropertiesFile=false/g' $JAVA_HOME/conf/security/java.security \
123+
&& true
124+
125+
# wait to create commit-specific LABEL until end of the build to not unnecessarily
126+
# invalidate the cached image layers
127+
ARG imageVersion
128+
ARG buildId
129+
ARG commitSha
130+
131+
RUN echo "${buildId}" > /opt/kserve/mmesh/build-version
132+
133+
LABEL name="model-mesh" \
134+
vendor="KServe" \
135+
version="${imageVersion}" \
136+
summary="Core model-mesh sidecar image" \
137+
description="Model-mesh is a distributed LRU cache for serving runtime models" \
138+
release="${commitSha}" \
139+
maintainer="[email protected]"
112140

113141
EXPOSE 8080
114142

Dockerfile.develop

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)