Skip to content

Commit 1e5e90c

Browse files
NopeCharonshuchu
authored andcommitted
fix: Build the Go feature server image in two stages
The go-feature-server image was built and shipped from the full golang:1.26 image, so every published tag carried the Go toolchain, gcc, protoc, the module and build caches, and Debian development packages such as linux-libc-dev. Those packages are flagged by container scanners (for example DSA-6238-1, DSA-6253-1, DSA-6274-1 and DSA-6295-1 against linux-libc-dev), and users cannot remediate them because they come from the base layer. Keep the existing build steps in a builder stage and copy only the compiled binary into a debian:trixie-slim runtime stage with ca-certificates. The builder is pinned to golang:1.26-trixie, which is what golang:1.26 resolves to today, so the cgo-linked binary (needed by go-sqlite3) runs against the same glibc release. The working directory, binary path, exposed port and default command are unchanged, so existing deployments that mount a feature repo under /app or pass --chdir keep working. The runtime image no longer contains linux-libc-dev, the Go toolchain or compilers, and drops from about 3.1 GB to about 214 MB. Fixes #7060 Signed-off-by: NopeCharon <[email protected]>
1 parent e304a84 commit 1e5e90c

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎go/infra/docker/feature-server/Dockerfile‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.26
1+
FROM golang:1.26-trixie AS builder
22
ENV GOTOOLCHAIN=auto
33

44
# Update the package list and install the ca-certificates package
@@ -24,6 +24,21 @@ RUN find ./protos -name "*.proto" \
2424
# Build the Go application
2525
RUN go build -o feast ./go/main.go
2626

27+
# Ship only the server binary on a slim base, so the Go toolchain, compilers and
28+
# kernel headers of the build image are not part of the published image. The
29+
# runtime uses the same Debian release as the builder, so the cgo-linked binary
30+
# finds a matching glibc.
31+
FROM debian:trixie-slim
32+
33+
# Update the package list and install the ca-certificates package
34+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
# Set the current working directory inside the container
38+
WORKDIR /app
39+
40+
COPY --from=builder /app/feast ./feast
41+
2742
# Expose ports
2843
EXPOSE 8080
2944

0 commit comments

Comments
 (0)