Skip to content

Commit 000ba33

Browse files
authored
Merge pull request red-hat-data-services#313 from VedantMahabaleshwarkar/eng-6506-rhoai
replace upstream Dockerfiles with ubi dockerfiles.
2 parents 9fb5f7d + 3a36537 commit 000ba33

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.21 as builder
2+
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
33

44
# Copy in the go src
55
WORKDIR /go/src/github.com/kserve/kserve
@@ -12,10 +12,17 @@ COPY cmd/ cmd/
1212
COPY pkg/ pkg/
1313

1414
# Build
15+
USER root
1516
RUN CGO_ENABLED=0 GOOS=linux GOFLAGS=-mod=mod go build -a -o manager ./cmd/manager
1617

17-
# Copy the controller-manager into a thin image
18-
FROM gcr.io/distroless/static:nonroot
18+
# Use distroless as minimal base image to package the manager binary
19+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
20+
RUN microdnf install -y shadow-utils && \
21+
microdnf clean all && \
22+
useradd kserve -m -u 1000
23+
RUN microdnf remove -y shadow-utils
1924
COPY third_party/ /third_party/
2025
COPY --from=builder /go/src/github.com/kserve/kserve/manager /
21-
ENTRYPOINT ["/manager"]
26+
USER 1000:1000
27+
28+
ENTRYPOINT ["/manager"]

agent.Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the inference-agent binary
2-
FROM golang:1.21 as builder
2+
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
33

44
# Copy in the go src
55
WORKDIR /go/src/github.com/kserve/kserve
@@ -11,11 +11,19 @@ COPY pkg/ pkg/
1111
COPY cmd/ cmd/
1212

1313
# Build
14+
USER root
1415
RUN CGO_ENABLED=0 GOOS=linux GOFLAGS=-mod=mod go build -a -o agent ./cmd/agent
1516

1617
# Copy the inference-agent into a thin image
17-
FROM gcr.io/distroless/static:nonroot
18+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
19+
20+
RUN microdnf install -y shadow-utils && \
21+
microdnf clean all && \
22+
useradd kserve -m -u 1000
23+
RUN microdnf remove -y shadow-utils
1824
COPY third_party/ third_party/
1925
WORKDIR /ko-app
2026
COPY --from=builder /go/src/github.com/kserve/kserve/agent /ko-app/
21-
ENTRYPOINT ["/ko-app/agent"]
27+
USER 1000:1000
28+
29+
ENTRYPOINT ["/ko-app/agent"]

python/storage-initializer.Dockerfile

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
ARG PYTHON_VERSION=3.9
2-
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi
32
ARG VENV_PATH=/prod_venv
43

5-
FROM ${BASE_IMAGE} as builder
4+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as builder
5+
6+
# Install Python and dependencies
7+
RUN microdnf install -y python39 python39-devel gcc libffi-devel openssl-devel krb5-workstation krb5-libs && microdnf clean all
68

79
# Install Poetry
810
ARG POETRY_HOME=/opt/poetry
911
ARG POETRY_VERSION=1.7.1
1012

11-
# Required for building packages for arm64 arch
12-
RUN yum -y update && yum -y install python39 python39-devel gcc
13-
14-
RUN python3 -m venv ${POETRY_HOME} && ${POETRY_HOME}/bin/pip install poetry==${POETRY_VERSION}
13+
RUN python -m venv ${POETRY_HOME} && ${POETRY_HOME}/bin/pip install poetry==${POETRY_VERSION}
1514
ENV PATH="$PATH:${POETRY_HOME}/bin"
1615

1716
# Activate virtual env
1817
ARG VENV_PATH
1918
ENV VIRTUAL_ENV=${VENV_PATH}
20-
RUN python3 -m venv $VIRTUAL_ENV
19+
RUN python -m venv $VIRTUAL_ENV
2120
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
2221

2322
# Addressing vulnerability scans by upgrading pip/setuptools
@@ -28,17 +27,11 @@ RUN cd kserve && poetry install --no-root --no-interaction --no-cache --extras "
2827
COPY kserve kserve
2928
RUN cd kserve && poetry install --no-interaction --no-cache --extras "storage"
3029

31-
RUN yum -y update && yum install -y \
32-
gcc \
33-
krb5-devel \
34-
&& rm -rf /var/lib/apt/lists/*
35-
3630
RUN pip install --no-cache-dir krbcontext==0.10 hdfs~=2.6.0 requests-kerberos==0.14.0
3731
# Fixes Quay alert GHSA-2jv5-9r88-3w3p https://github.com/Kludex/python-multipart/security/advisories/GHSA-2jv5-9r88-3w3p
3832
RUN pip install --no-cache-dir starlette==0.36.2
3933

40-
41-
FROM registry.access.redhat.com/ubi8/ubi-minimal as prod
34+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as prod
4235

4336
COPY third_party third_party
4437

@@ -47,8 +40,9 @@ ARG VENV_PATH
4740
ENV VIRTUAL_ENV=${VENV_PATH}
4841
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
4942

50-
RUN microdnf install python39 shadow-utils
51-
RUN adduser kserve -m -u 1000 -d /home/kserve
43+
RUN microdnf install -y shadow-utils python39 python39-devel && \
44+
microdnf clean all
45+
RUN useradd kserve -m -u 1000 -d /home/kserve
5246

5347
COPY --from=builder --chown=kserve:kserve $VIRTUAL_ENV $VIRTUAL_ENV
5448
COPY --from=builder kserve kserve

router.Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the inference-router binary
2-
FROM golang:1.21 as builder
2+
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
33

44
# Copy in the go src
55
WORKDIR /go/src/github.com/kserve/kserve
@@ -12,11 +12,18 @@ COPY pkg/ pkg/
1212
COPY cmd/ cmd/
1313

1414
# Build
15+
USER root
1516
RUN CGO_ENABLED=0 go build -a -o router ./cmd/router
1617

1718
# Copy the inference-router into a thin image
18-
FROM gcr.io/distroless/static:nonroot
19+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
20+
RUN microdnf install -y shadow-utils && \
21+
microdnf clean all && \
22+
useradd kserve -m -u 1000
23+
RUN microdnf remove -y shadow-utils
1924
COPY third_party/ third_party/
2025
WORKDIR /ko-app
2126
COPY --from=builder /go/src/github.com/kserve/kserve/router /ko-app/
22-
ENTRYPOINT ["/ko-app/router"]
27+
USER 1000:1000
28+
29+
ENTRYPOINT ["/ko-app/router"]

0 commit comments

Comments
 (0)