mirror of
https://github.com/hanzo-ml/kserve.git
synced 2026-10-30 20:53:49 +00:00
41 lines
1.2 KiB
Docker
41 lines
1.2 KiB
Docker
# Build the inference-router binary
|
|
FROM golang:1.25 AS deps
|
|
|
|
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
|
|
ARG GOTAGS=""
|
|
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 -tags "${GOTAGS}" -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 save --save_path /third_party/library ./cmd/${CMD}
|
|
|
|
# Copy the inference-router into a thin image
|
|
FROM gcr.io/distroless/static:nonroot
|
|
COPY --from=license /third_party /third_party
|
|
WORKDIR /ko-app
|
|
COPY --from=builder /go/src/github.com/kserve/kserve/router /ko-app/
|
|
ENTRYPOINT ["/ko-app/router"]
|