# syntax=docker/dockerfile:1 # GO_VERSION sets the version of the golang base image to use. # It must be a valid tag in the docker.io/library/golang image repository. ARG GO_VERSION=1.26.3 # BASE_DEBIAN_DISTRO sets the golang base image debian variant to use. # It must be a valid variant in the docker.io/library/golang image repository. ARG BASE_DEBIAN_DISTRO=bookworm # XX_VERSION sets the version of the xx utility to use. # It must be a valid tag in the docker.io/tonistiigi/xx image repository. ARG XX_VERSION=1.9.0 # OSXCROSS_VERSION sets the MacOSX cross toolchain to use. # It must be a valid tag in the docker.io/crazymax/osxcross image repository. ARG OSXCROSS_VERSION=11.3-r8-debian # GOLANGCI_LINT_VERSION sets the version of the golangci-lint image to use. # It must be a valid tag in the docker.io/golangci/golangci-lint image repository. ARG GOLANGCI_LINT_VERSION=v2.11 # PACKAGE sets the package name to print in the "--version" output. # It sets the "github.com/docker/docker-credential-helpers/credentials.Package # variable at compile time. ARG PACKAGE=github.com/docker/docker-credential-helpers # xx is a helper for cross-compilation FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx # osxcross contains the MacOSX cross toolchain for xx FROM crazymax/osxcross:${OSXCROSS_VERSION} AS osxcross FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO} AS gobase COPY --from=xx / / RUN apt-get update && apt-get install -y --no-install-recommends clang dpkg-dev file git lld llvm make pkg-config rsync ENV GOFLAGS="-mod=vendor" ENV CGO_ENABLED="1" WORKDIR /src FROM gobase AS vendored RUN --mount=target=/context \ --mount=target=.,type=tmpfs \ --mount=target=/go/pkg/mod,type=cache <&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"' git status --porcelain -- go.mod go.sum vendor exit 1 fi EOT FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS golangci-lint FROM gobase AS lint RUN apt-get install -y binutils gcc libc6-dev libgcc-11-dev libsecret-1-dev pkg-config RUN --mount=type=bind,target=. \ --mount=type=cache,target=/root/.cache \ --mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \ golangci-lint run ./... FROM gobase AS base ARG TARGETPLATFORM RUN xx-apt-get install -y binutils gcc libc6-dev libgcc-11-dev libsecret-1-dev pkg-config FROM base AS test RUN xx-apt-get install -y dbus-x11 gnome-keyring gpg-agent gpgconf libsecret-1-dev pass RUN --mount=type=bind,target=. \ --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/go/pkg/mod <