# Binary-only Grafana rebuild. The quarry guest cannot hold the 13-plugin # no-cache recipe (run 432 filled the disk from about 30 GiB free). This file # compiles cmd/grafana with the same bumps and replaces the binary on the # published image, whose bundled plugins stay in place. ARG GO_IMAGE=docker.io/library/golang:1.27.2-alpine3.24@sha256:85dc1069ac644ea3c527b177303a406eb3358192816cd7f9e5848eb658851673 ARG BASE_IMAGE FROM ${BASE_IMAGE} AS original FROM ${GO_IMAGE} AS build LABEL io.thepeoples.hardened.build-owner="hardened-batch3" ARG SOURCE_URL=https://codeload.github.com/grafana/grafana/tar.gz/6193dc03311b631b9727b560d24369e683dc396e ARG SOURCE_SHA256=222f8cd14b5345d024ab460d592c63c1e7432cb20a89e2dbcc86d7bfd83df3ac ARG SOURCE_COMMIT=6193dc03311b631b9727b560d24369e683dc396e ARG VERSION=13.2.3 ARG BUILD_STAMP=1790672538 ARG GO_BUMPS="golang.org/x/net@v0.60.0 golang.org/x/crypto@v0.57.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace@v1.45.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc@v1.45.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp@v1.45.0 github.com/getkin/kin-openapi@v0.149.0" ENV GOWORK=off GOTOOLCHAIN=local CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOMAXPROCS=1 GOMODCACHE=/go/pkg/mod GOCACHE=/go/cache WORKDIR /src COPY verification/ /inputs/verification/ COPY plugins.tsv /inputs/plugins.tsv COPY --from=original /usr/share/grafana/data/plugins-bundled/ /usr/share/grafana/data/plugins-bundled/ RUN wget -q -O /tmp/upstream.tar.gz "${SOURCE_URL}" \ && printf '%s %s\n' "${SOURCE_SHA256}" /tmp/upstream.tar.gz | sha256sum -c - \ && tar -xzf /tmp/upstream.tar.gz --strip-components=1 -C /src \ && go run /inputs/verification/apply.go /inputs/verification/distributor.patch /src \ && cp /inputs/verification/distributor.go /inputs/verification/distributor_test.go pkg/plugins/manager/signature/ \ && go run /inputs/verification/generate.go /usr/share/grafana/data/plugins-bundled /usr/share/grafana/data/plugins-bundled /inputs/plugins.tsv pkg/plugins/manager/signature/distributor_generated.go \ && gofmt -w pkg/plugins/manager/signature/distributor*.go pkg/plugins/models.go \ && mkdir -p /out/bin /out/records \ && cp go.mod /out/records/upstream.go.mod \ && cp go.sum /out/records/upstream.go.sum \ && if [ -n "${GO_BUMPS}" ]; then go get ${GO_BUMPS}; fi \ && go mod download \ && go mod verify \ && go test -p 1 -tags oss -mod=readonly -run '^TestDistributor' -v github.com/grafana/grafana/pkg/plugins/manager/signature \ && rm -rf /tmp/go-build \ && cp pkg/plugins/manager/signature/distributor_generated.go /out/records/ \ && go build -p 1 -tags oss -mod=readonly -buildvcs=false -trimpath -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${SOURCE_COMMIT} -X main.buildBranch=hardened -X main.buildstamp=${BUILD_STAMP}" -o /out/bin/grafana ./pkg/cmd/grafana \ && go version -m /out/bin/grafana > /out/records/go-version-m.txt \ && go list -m -json all > /out/records/modules.json \ && printf '%s\n' "${SOURCE_COMMIT}" > /out/records/upstream-commit \ && printf '%s\n' "${GO_BUMPS}" > /out/records/bumps \ && cp go.mod go.sum LICENSE /out/records/ \ && if [ -f NOTICE ]; then cp NOTICE /out/records/; fi \ && cd / \ && rm -rf /src /go /tmp/go-build /tmp/upstream.tar.gz /usr/share/grafana FROM ${BASE_IMAGE} USER root COPY --from=build --chmod=0755 /out/bin/grafana /usr/share/grafana/bin/grafana COPY --from=build /out/records/ /usr/share/tp-hardened/grafana/ USER 472 LABEL io.thepeoples.hardened.rebuild="binary" \ io.thepeoples.hardened.ladder="binary+minimize"