# vmsingle only. The official release archive includes vendor/ and embedded VMUI. ARG GO_IMAGE=docker.io/library/golang:1.27.3-alpine3.24@sha256:f2c872bcee949b7be9c490efd02b48a8a2fbf947cdf533f1c58525ec9d8170fd FROM ${GO_IMAGE} AS build LABEL io.thepeoples.hardened.build-owner="hardened-batch4" ARG SOURCE_URL=https://github.com/VictoriaMetrics/VictoriaMetrics/archive/refs/tags/v1.154.0.tar.gz ARG SOURCE_SHA256=58af274d6088698d71ead526b280aafde96f8e26578db58fd91e9bbbfac0d561 ARG SOURCE_COMMIT=29c43cd2fee05409499a4d1b38e950e1b7f13bd4 ARG VERSION=v1.154.0 ARG GO_BUMPS="" ENV GOTOOLCHAIN=local CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOMAXPROCS=4 WORKDIR /src 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 # Stable cache IDs share caches across builds, rather than retaining a cache per slice. RUN --mount=type=cache,id=hardened-go-build,target=/root/.cache/go-build \ --mount=type=cache,id=hardened-go-mod,target=/go/pkg/mod \ mkdir -p /out/records /out/source /out/rootfs/storage /out/rootfs/tmp /out/rootfs/etc \ && cp go.mod go.sum /out/records/ \ && if [ -n "${GO_BUMPS}" ]; then \ GOFLAGS=-mod=mod go get ${GO_BUMPS} \ && go mod download && go mod verify && go mod vendor; \ fi \ && go build -p 4 -mod=vendor -buildvcs=false -trimpath \ -tags 'netgo osusergo' \ -ldflags "-s -w -X github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=victoria-metrics-${VERSION}-hardened-${SOURCE_COMMIT}" \ -o /out/victoria-metrics-prod ./app/victoria-metrics \ && go version -m /out/victoria-metrics-prod > /out/records/go-version-m.txt \ && cp vendor/modules.txt /out/records/vendor-modules.txt \ && cp go.mod /out/records/effective.go.mod \ && cp go.sum /out/records/effective.go.sum \ && cp LICENSE /out/records/ \ && if [ -f NOTICE ]; then cp NOTICE /out/records/; fi \ && printf '%s\n' "${SOURCE_COMMIT}" > /out/records/upstream-commit \ && printf '%s\n' "${GO_BUMPS}" > /out/records/bumps \ && printf 'nonroot:x:65532:65532:nonroot:/storage:/sbin/nologin\n' > /out/rootfs/etc/passwd \ && printf 'nonroot:x:65532:\n' > /out/rootfs/etc/group \ && chmod 1777 /out/rootfs/tmp \ && cp /tmp/upstream.tar.gz /out/source/victoria-metrics-${VERSION}.tar.gz \ && cp -R /out/records /out/source/records \ && if [ -n "${GO_BUMPS}" ]; then tar -czf /out/source/vendor.tar.gz vendor; fi \ && cd /out/source && sha256sum *.tar.gz records/* > SHA256SUMS FROM scratch AS source LABEL io.thepeoples.hardened.build-owner="hardened-batch4" COPY --from=build /out/source/ / FROM scratch ARG GO_IMAGE COPY --from=build --chown=65532:65532 /out/rootfs/ / COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=build --chmod=0755 /out/victoria-metrics-prod /victoria-metrics-prod COPY --from=build /out/records/ /usr/share/tp-hardened/victoria-metrics/ USER 65532:65532 WORKDIR / EXPOSE 8428 ENTRYPOINT ["/victoria-metrics-prod"] CMD ["-storageDataPath=/storage", "-retentionPeriod=14d", "-httpListenAddr=:8428"] LABEL org.opencontainers.image.version="v1.154.0" \ org.opencontainers.image.source="https://github.com/VictoriaMetrics/VictoriaMetrics" \ org.opencontainers.image.revision="29c43cd2fee05409499a4d1b38e950e1b7f13bd4" \ org.opencontainers.image.licenses="Apache-2.0" \ io.thepeoples.hardened.distribution="vmsingle" \ io.thepeoples.hardened.ladder="b+minimize" \ io.thepeoples.hardened.toolchain="${GO_IMAGE}" \ io.thepeoples.hardened.source-status="upstream release tarball plus this Containerfile and recorded module changes"