1+ # Copyright 2026 Docker, Inc.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
115# syntax=docker/dockerfile:1
216
17+ ARG ALPINE_VERSION=3.23.3
318ARG GO_VERSION=latest
419ARG GOLANGCI_LINT_VERSION=v2.2.1
520ARG OSXCROSS_VERSION=15.5
21+ ARG ADDLICENSE_VERSION=v1.2.0
22+ ARG LICENSE_ARGS="-c 'Docker, Inc.' -l apache -ignore '**/*.yaml' -ignore '**/*.yml' -ignore '.github/**' -ignore 'store/keychain/internal/go-keychain/**' -ignore 'vendor/**' -ignore '.git/**' ."
23+
24+ FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
625
726FROM --platform=${BUILDPLATFORM} golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS lint-base
827
@@ -13,6 +32,32 @@ FROM --platform=${BUILDPLATFORM} crazymax/osxcross:${OSXCROSS_VERSION}-alpine AS
1332FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS gobase
1433RUN apk add --no-cache findutils build-base git
1534
35+ FROM alpine:${ALPINE_VERSION} AS license-validate
36+ ARG LICENSE_ARGS
37+ COPY --link --from=addlicense /app/addlicense /usr/bin/addlicense
38+ WORKDIR /src
39+ RUN --mount=type=bind,target=.,ro <<EOT
40+ set -eu
41+ echo "== Checking license headers =="
42+ eval "/usr/bin/addlicense -check $LICENSE_ARGS"
43+ EOT
44+
45+ FROM alpine:${ALPINE_VERSION} AS do-license-update
46+ ARG LICENSE_ARGS
47+ COPY --from=addlicense /app/addlicense /usr/bin/addlicense
48+ RUN mkdir -p /generate/out
49+ WORKDIR /src
50+ RUN apk add --no-cache git
51+ RUN --mount=type=bind,target=.,rw <<EOT
52+ set -eu
53+ echo "== Checking license headers =="
54+ eval "/usr/bin/addlicense -v $LICENSE_ARGS"
55+ ./scripts/copy-only-diff /generate/out
56+ EOT
57+
58+ FROM scratch AS license-update
59+ COPY --from=do-license-update /generate/out .
60+
1661FROM gobase AS linux-base
1762ARG TARGETARCH
1863ENV GOOS=linux
0 commit comments