From e9c36a5d986874cea235d595c80650b41550b7a2 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 11 Nov 2026 13:22:48 +0000 Subject: [PATCH] fix: rebuild with patched packages and Go The upstream postgres image ships gosu 1.20 built with Go 1.24.6, which Trivy flags for 26 stdlib CVEs. Build gosu from its 1.20 tag with Go 1.27.4 instead. Debian package fixes come from rebuilding on the current postgres base with the existing apt-get upgrade. --- Dockerfile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 869ecb8..ab3188e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,24 @@ ARG PG_MAJOR=18 +# The upstream image ships gosu built with Go 1.24.6; rebuild it with a patched Go. +FROM --platform=$BUILDPLATFORM golang:1.27.4-trixie AS gosu + +ARG GOSU_VERSION=1.20 +ARG TARGETARCH + +WORKDIR /src +RUN git clone --depth 1 --branch "${GOSU_VERSION}" https://github.com/tianon/gosu.git . && \ + CGO_ENABLED=0 GOARCH="${TARGETARCH}" go build -trimpath -ldflags '-d -w' -o /gosu . + FROM postgres:${PG_MAJOR} ARG PG_MAJOR +COPY --from=gosu /gosu /usr/local/bin/gosu + # hadolint ignore=DL3008 -RUN apt-get update && \ +RUN gosu nobody true && \ + apt-get update && \ apt-get upgrade -y && \ apt-get install -y --no-install-recommends \ postgresql-${PG_MAJOR}-pgvector \