forked from kserve/kserve
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrouter.Dockerfile
More file actions
51 lines (40 loc) · 1.65 KB
/
router.Dockerfile
File metadata and controls
51 lines (40 loc) · 1.65 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
50
51
# Build the inference-router 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=router
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 router ./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/[email protected]
ARG CMD=router
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}
# Copy the inference-router 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
WORKDIR /ko-app
COPY --from=builder /go/src/github.com/kserve/kserve/router /ko-app/
USER 1000:1000
ENTRYPOINT ["/ko-app/router"]