forked from opendatahub-io/kserve
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (39 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
49 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Build the manager binary
FROM registry.access.redhat.com/ubi9/go-toolset:1.25 AS deps
# distro: UBI go-toolset does not add GOPATH/bin to PATH
ENV PATH="$PATH:/opt/app-root/src/go/bin"
WORKDIR /go/src/github.com/kserve/kserve
COPY go.mod go.mod
COPY go.sum go.sum
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# ---- Build stage (parallel with license on BuildKit) ----
FROM deps AS builder
ARG CMD=manager
COPY cmd/${CMD}/ cmd/${CMD}/
COPY pkg/ pkg/
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOFLAGS=-mod=readonly go build -a -o manager ./cmd/${CMD}
# ---- License stage (parallel with build on BuildKit) ----
FROM deps AS license
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go install github.com/google/go-licenses@v1.6.0
ARG CMD=manager
COPY cmd/${CMD}/ cmd/${CMD}/
COPY pkg/ pkg/
COPY LICENSE LICENSE
RUN --mount=type=cache,target=/go/pkg/mod \
go-licenses check ./cmd/${CMD} ./pkg/... --disallowed_types="forbidden,unknown" && \
go-licenses save --save_path third_party/library ./cmd/${CMD}
# Runtime image - Copy the controller-manager into a thin image
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
RUN microdnf install -y --disablerepo=* --enablerepo=ubi-9-baseos-rpms shadow-utils && \
microdnf clean all && \
useradd kserve -m -u 1000
RUN microdnf remove -y shadow-utils
COPY --from=license /go/src/github.com/kserve/kserve/third_party /third_party
COPY --from=builder /go/src/github.com/kserve/kserve/manager /manager
USER 1000:1000
ENTRYPOINT ["/manager"]