|
| 1 | +# Copyright 2025 The llm-d Authors. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Build Stage: using Go 1.24.1 image |
| 16 | +FROM quay.io/projectquay/golang:1.24 AS builder |
| 17 | +ARG TARGETOS |
| 18 | +ARG TARGETARCH |
| 19 | + |
| 20 | +WORKDIR /workspace |
| 21 | + |
| 22 | +# Install system-level dependencies first. This layer is very stable. |
| 23 | +USER root |
| 24 | +# Install EPEL repository directly and then ZeroMQ, as epel-release is not in default repos. |
| 25 | +# Install all necessary dependencies including Python 3.12 for chat-completions templating. |
| 26 | +# The builder is based on UBI8, so we need epel-release-8. |
| 27 | +RUN dnf install -y 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm' && \ |
| 28 | + dnf install -y gcc-c++ libstdc++ libstdc++-devel clang zeromq-devel pkgconfig && \ |
| 29 | + dnf clean all |
| 30 | + |
| 31 | +# Copy the Go Modules manifests |
| 32 | +COPY go.mod go.mod |
| 33 | +COPY go.sum go.sum |
| 34 | +# cache deps before building and copying source so that we don't need to re-download as much |
| 35 | +# and so that source changes don't invalidate our downloaded layer |
| 36 | +RUN go mod download |
| 37 | + |
| 38 | +# Copy the source code. |
| 39 | +COPY . . |
| 40 | + |
| 41 | +RUN make build-uds |
| 42 | + |
| 43 | +# Use distroless as minimal base image to package the manager binary |
| 44 | +# Refer to https://github.com/GoogleContainerTools/distroless for more details |
| 45 | +FROM registry.access.redhat.com/ubi9/ubi:latest |
| 46 | +WORKDIR / |
| 47 | +# Install zeromq runtime library needed by the manager. |
| 48 | +# The final image is UBI9, so we need epel-release-9. |
| 49 | +USER root |
| 50 | +RUN dnf install -y 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm' && \ |
| 51 | + dnf install -y zeromq libxcrypt-compat && \ |
| 52 | + dnf clean all |
| 53 | + |
| 54 | +# Copy the compiled Go application |
| 55 | +COPY --from=builder /workspace/bin/llm-d-kv-cache /app/kv-cache-manager |
| 56 | +USER 65532:65532 |
| 57 | + |
| 58 | +# Set the entrypoint to the kv-cache-manager binary |
| 59 | +ENTRYPOINT ["/app/kv-cache-manager"] |
0 commit comments