mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
Bake workflow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b05c313204
commit
6cfef7fa36
144
.github/workflows/build.yml
vendored
144
.github/workflows/build.yml
vendored
@ -16,61 +16,15 @@ on:
|
|||||||
env:
|
env:
|
||||||
REPO_SLUG: "docker/buildx-bin"
|
REPO_SLUG: "docker/buildx-bin"
|
||||||
REPO_SLUG_ORIGIN: "moby/buildkit:master"
|
REPO_SLUG_ORIGIN: "moby/buildkit:master"
|
||||||
CACHEKEY_BINARIES: "binaries"
|
RELEASE_OUT: "./release-out"
|
||||||
PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
base:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
|
||||||
name: Cache ${{ env.CACHEKEY_BINARIES }}
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
key: ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
|
|
||||||
-
|
|
||||||
name: Build ${{ env.CACHEKEY_BINARIES }}
|
|
||||||
run: |
|
|
||||||
./hack/build_ci_first_pass binaries
|
|
||||||
env:
|
|
||||||
CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
CACHEDIR_TO: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}-new
|
|
||||||
-
|
|
||||||
# FIXME: Temp fix for https://github.com/moby/buildkit/issues/1850
|
|
||||||
name: Move cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
mv /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}-new /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [base]
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Cache ${{ env.CACHEKEY_BINARIES }}
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
key: ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-
|
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
@ -83,91 +37,15 @@ jobs:
|
|||||||
name: Test
|
name: Test
|
||||||
run: |
|
run: |
|
||||||
make test
|
make test
|
||||||
env:
|
|
||||||
TEST_COVERAGE: 1
|
|
||||||
TESTFLAGS: -v --parallel=6 --timeout=20m
|
|
||||||
CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
-
|
-
|
||||||
name: Send to Codecov
|
name: Send to Codecov
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
with:
|
with:
|
||||||
file: ./coverage/coverage.txt
|
file: ./coverage/coverage.txt
|
||||||
|
|
||||||
cross:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [base]
|
|
||||||
steps:
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Build binaries
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Cache ${{ env.CACHEKEY_BINARIES }}
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
key: ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
|
|
||||||
-
|
|
||||||
name: Cross
|
|
||||||
run: |
|
run: |
|
||||||
make cross
|
make release
|
||||||
env:
|
|
||||||
TARGETPLATFORM: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
|
|
||||||
CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
|
|
||||||
binaries:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [test, cross]
|
|
||||||
env:
|
|
||||||
RELEASE_OUT: ./release-out
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Prepare
|
|
||||||
id: prep
|
|
||||||
run: |
|
|
||||||
TAG=pr
|
|
||||||
if [[ $GITHUB_REF == refs/tags/v* ]]; then
|
|
||||||
TAG=${GITHUB_REF#refs/tags/}
|
|
||||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
||||||
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
|
||||||
fi
|
|
||||||
echo ::set-output name=tag::${TAG}
|
|
||||||
-
|
|
||||||
name: Cache ${{ env.CACHEKEY_BINARIES }}
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
key: ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
|
|
||||||
-
|
|
||||||
name: Build ${{ steps.prep.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
./hack/release ${{ env.RELEASE_OUT }}
|
|
||||||
env:
|
|
||||||
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
|
|
||||||
CHECKSUMS: 1
|
|
||||||
CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
-
|
-
|
||||||
name: Upload artifacts
|
name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
@ -186,6 +64,7 @@ jobs:
|
|||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
bake-target: meta-helper
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@ -195,15 +74,13 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push image
|
name: Build and push image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/bake-action@v1
|
||||||
with:
|
with:
|
||||||
context: .
|
files: |
|
||||||
target: binaries
|
./docker-bake.hcl
|
||||||
|
${{ steps.meta.outputs.bake-file }}
|
||||||
|
targets: image-cross
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
|
|
||||||
platforms: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
-
|
-
|
||||||
name: GitHub Release
|
name: GitHub Release
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
@ -213,4 +90,3 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
files: ${{ env.RELEASE_OUT }}/*
|
files: ${{ env.RELEASE_OUT }}/*
|
||||||
name: ${{ steps.prep.outputs.tag }}
|
|
||||||
|
8
.github/workflows/validate.yml
vendored
8
.github/workflows/validate.yml
vendored
@ -13,9 +13,6 @@ on:
|
|||||||
- 'master'
|
- 'master'
|
||||||
- 'v[0-9]*'
|
- 'v[0-9]*'
|
||||||
|
|
||||||
env:
|
|
||||||
REPO_SLUG_ORIGIN: "moby/buildkit:master"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -30,11 +27,6 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
|
|
||||||
-
|
-
|
||||||
name: Run
|
name: Run
|
||||||
run: |
|
run: |
|
||||||
|
9
.mailmap
9
.mailmap
@ -1,6 +1,13 @@
|
|||||||
# This file lists all individuals having contributed content to the repository.
|
# This file lists all individuals having contributed content to the repository.
|
||||||
# For how it is generated, see `hack/generate-authors`.
|
# For how it is generated, see hack/dockerfiles/authors.Dockerfile.
|
||||||
|
|
||||||
|
CrazyMax <github@crazymax.dev>
|
||||||
|
CrazyMax <github@crazymax.dev> <1951866+crazy-max@users.noreply.github.com>
|
||||||
|
CrazyMax <github@crazymax.dev> <crazy-max@users.noreply.github.com>
|
||||||
|
Sebastiaan van Stijn <github@gone.nl>
|
||||||
|
Sebastiaan van Stijn <github@gone.nl> <thaJeztah@users.noreply.github.com>
|
||||||
Tibor Vass <tibor@docker.com>
|
Tibor Vass <tibor@docker.com>
|
||||||
Tibor Vass <tibor@docker.com> <tiborvass@users.noreply.github.com>
|
Tibor Vass <tibor@docker.com> <tiborvass@users.noreply.github.com>
|
||||||
Tõnis Tiigi <tonistiigi@gmail.com>
|
Tõnis Tiigi <tonistiigi@gmail.com>
|
||||||
|
Ulysses Souza <ulyssessouza@gmail.com>
|
||||||
|
Wang Jinglei <morlay.null@gmail.com>
|
||||||
|
40
AUTHORS
40
AUTHORS
@ -1,7 +1,45 @@
|
|||||||
# This file lists all individuals having contributed content to the repository.
|
# This file lists all individuals having contributed content to the repository.
|
||||||
# For how it is generated, see `scripts/generate-authors.sh`.
|
# For how it is generated, see hack/dockerfiles/authors.Dockerfile.
|
||||||
|
|
||||||
|
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
|
||||||
|
Alex Couture-Beil <alex@earthly.dev>
|
||||||
|
Andrew Haines <andrew.haines@zencargo.com>
|
||||||
|
Andy MacKinlay <admackin@users.noreply.github.com>
|
||||||
|
Anthony Poschen <zanven42@gmail.com>
|
||||||
|
Artur Klauser <Artur.Klauser@computer.org>
|
||||||
|
Batuhan Apaydın <developerguy2@gmail.com>
|
||||||
Bin Du <bindu@microsoft.com>
|
Bin Du <bindu@microsoft.com>
|
||||||
|
Brandon Philips <brandon@ifup.org>
|
||||||
Brian Goff <cpuguy83@gmail.com>
|
Brian Goff <cpuguy83@gmail.com>
|
||||||
|
CrazyMax <github@crazymax.dev>
|
||||||
|
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
||||||
|
Devin Bayer <dev@doubly.so>
|
||||||
|
Djordje Lukic <djordje.lukic@docker.com>
|
||||||
|
Dmytro Makovey <dmytro.makovey@docker.com>
|
||||||
|
Donghui Wang <977675308@qq.com>
|
||||||
|
faust <faustin@fala.red>
|
||||||
|
Felipe Santos <felipecassiors@gmail.com>
|
||||||
|
Fernando Miguel <github@FernandoMiguel.net>
|
||||||
|
gfrancesco <gfrancesco@users.noreply.github.com>
|
||||||
|
gracenoah <gracenoahgh@gmail.com>
|
||||||
|
Hollow Man <hollowman@hollowman.ml>
|
||||||
|
Ilya Dmitrichenko <errordeveloper@gmail.com>
|
||||||
|
Jack Laxson <jackjrabbit@gmail.com>
|
||||||
|
Jean-Yves Gastaud <jygastaud@gmail.com>
|
||||||
|
khs1994 <khs1994@khs1994.com>
|
||||||
|
Kotaro Adachi <k33asby@gmail.com>
|
||||||
|
l00397676 <lujingxiao@huawei.com>
|
||||||
|
Michal Augustyn <michal.augustyn@mail.com>
|
||||||
|
Patrick Van Stee <patrick@vanstee.me>
|
||||||
|
Saul Shanabrook <s.shanabrook@gmail.com>
|
||||||
|
Sebastiaan van Stijn <github@gone.nl>
|
||||||
|
SHIMA Tatsuya <ts1s1andn@gmail.com>
|
||||||
|
Silvin Lubecki <silvin.lubecki@docker.com>
|
||||||
|
Solomon Hykes <sh.github.6811@hykes.org>
|
||||||
|
Sune Keller <absukl@almbrand.dk>
|
||||||
Tibor Vass <tibor@docker.com>
|
Tibor Vass <tibor@docker.com>
|
||||||
Tõnis Tiigi <tonistiigi@gmail.com>
|
Tõnis Tiigi <tonistiigi@gmail.com>
|
||||||
|
Ulysses Souza <ulyssessouza@gmail.com>
|
||||||
|
Wang Jinglei <morlay.null@gmail.com>
|
||||||
|
Xiang Dai <764524258@qq.com>
|
||||||
|
zelahi <elahi.zuhayr@gmail.com>
|
||||||
|
38
Dockerfile
38
Dockerfile
@ -1,8 +1,7 @@
|
|||||||
# syntax=docker/dockerfile:1.3
|
# syntax=docker/dockerfile:1.3
|
||||||
|
|
||||||
ARG GO_VERSION=1.17.0
|
ARG GO_VERSION=1.17.0
|
||||||
ARG DOCKERD_VERSION=19.03
|
ARG DOCKERD_VERSION=20.10.8
|
||||||
ARG CLI_VERSION=19.03
|
|
||||||
|
|
||||||
FROM docker:$DOCKERD_VERSION AS dockerd-release
|
FROM docker:$DOCKERD_VERSION AS dockerd-release
|
||||||
|
|
||||||
@ -26,24 +25,22 @@ RUN --mount=target=. \
|
|||||||
FROM gobase AS buildx-build
|
FROM gobase AS buildx-build
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
RUN --mount=target=. --mount=target=/root/.cache,type=cache \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=target=/go/pkg/mod,type=cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
--mount=source=/tmp/.ldflags,target=/tmp/.ldflags,from=buildx-version \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=bind,source=/tmp/.ldflags,target=/tmp/.ldflags,from=buildx-version \
|
||||||
set -x; xx-go build -ldflags "$(cat /tmp/.ldflags)" -o /usr/bin/buildx ./cmd/buildx && \
|
set -x; xx-go build -ldflags "$(cat /tmp/.ldflags)" -o /usr/bin/buildx ./cmd/buildx && \
|
||||||
xx-verify --static /usr/bin/buildx
|
xx-verify --static /usr/bin/buildx
|
||||||
|
|
||||||
FROM buildx-build AS integration-tests
|
FROM buildx-build AS test
|
||||||
COPY . .
|
RUN --mount=type=bind,target=. \
|
||||||
|
--mount=type=cache,target=/root/.cache \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./... && \
|
||||||
|
go tool cover -func=/tmp/coverage.txt
|
||||||
|
|
||||||
# FROM golang:1.12-alpine AS docker-cli-build
|
FROM scratch AS test-coverage
|
||||||
# RUN apk add -U git bash coreutils gcc musl-dev
|
COPY --from=test /tmp/coverage.txt /coverage.txt
|
||||||
# ENV CGO_ENABLED=0
|
|
||||||
# ARG REPO=github.com/tiborvass/cli
|
|
||||||
# ARG BRANCH=cli-plugin-aliases
|
|
||||||
# ARG CLI_VERSION
|
|
||||||
# WORKDIR /go/src/github.com/docker/cli
|
|
||||||
# RUN git clone git://$REPO . && git checkout $BRANCH
|
|
||||||
# RUN ./scripts/build/binary
|
|
||||||
|
|
||||||
FROM scratch AS binaries-unix
|
FROM scratch AS binaries-unix
|
||||||
COPY --from=buildx-build /usr/bin/buildx /
|
COPY --from=buildx-build /usr/bin/buildx /
|
||||||
@ -56,24 +53,25 @@ COPY --from=buildx-build /usr/bin/buildx /buildx.exe
|
|||||||
|
|
||||||
FROM binaries-$TARGETOS AS binaries
|
FROM binaries-$TARGETOS AS binaries
|
||||||
|
|
||||||
|
# Release
|
||||||
FROM --platform=$BUILDPLATFORM alpine AS releaser
|
FROM --platform=$BUILDPLATFORM alpine AS releaser
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
RUN --mount=from=binaries \
|
RUN --mount=from=binaries \
|
||||||
--mount=source=/tmp/.version,target=/tmp/.version,from=buildx-version \
|
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=buildx-version \
|
||||||
mkdir -p /out && cp buildx* "/out/buildx-$(cat /tmp/.version).$(echo $TARGETPLATFORM | sed 's/\//-/g')$(ls buildx* | sed -e 's/^buildx//')"
|
mkdir -p /out && cp buildx* "/out/buildx-$(cat /tmp/.version).$(echo $TARGETPLATFORM | sed 's/\//-/g')$(ls buildx* | sed -e 's/^buildx//')"
|
||||||
|
|
||||||
FROM scratch AS release
|
FROM scratch AS release
|
||||||
COPY --from=releaser /out/ /
|
COPY --from=releaser /out/ /
|
||||||
|
|
||||||
FROM alpine AS demo-env
|
# Shell
|
||||||
|
FROM docker:$DOCKERD_VERSION AS dockerd-release
|
||||||
|
FROM alpine AS shell
|
||||||
RUN apk add --no-cache iptables tmux git vim less openssh
|
RUN apk add --no-cache iptables tmux git vim less openssh
|
||||||
RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx
|
RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx
|
||||||
COPY ./hack/demo-env/entrypoint.sh /usr/local/bin
|
COPY ./hack/demo-env/entrypoint.sh /usr/local/bin
|
||||||
COPY ./hack/demo-env/tmux.conf /root/.tmux.conf
|
COPY ./hack/demo-env/tmux.conf /root/.tmux.conf
|
||||||
COPY --from=dockerd-release /usr/local/bin /usr/local/bin
|
COPY --from=dockerd-release /usr/local/bin /usr/local/bin
|
||||||
#COPY --from=docker-cli-build /go/src/github.com/docker/cli/build/docker /usr/local/bin
|
|
||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
COPY ./hack/demo-env/examples .
|
COPY ./hack/demo-env/examples .
|
||||||
COPY --from=binaries / /usr/local/bin/
|
COPY --from=binaries / /usr/local/bin/
|
||||||
|
54
Makefile
54
Makefile
@ -1,40 +1,56 @@
|
|||||||
|
ifneq (, $(BUILDX_BIN))
|
||||||
|
export BUILDX_CMD = $(BUILDX_BIN)
|
||||||
|
else ifneq (, $(shell docker buildx version))
|
||||||
|
export BUILDX_CMD = docker buildx
|
||||||
|
else ifneq (, $(shell which buildx))
|
||||||
|
export BUILDX_CMD = $(which buildx)
|
||||||
|
else
|
||||||
|
$(error "Buildx is required: https://github.com/docker/buildx#installing")
|
||||||
|
endif
|
||||||
|
|
||||||
|
export BIN_OUT = ./bin
|
||||||
|
export RELEASE_OUT = ./release-out
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
./hack/shell
|
./hack/shell
|
||||||
|
|
||||||
binaries:
|
binaries:
|
||||||
./hack/binaries
|
$(BUILDX_CMD) bake binaries
|
||||||
|
|
||||||
binaries-cross:
|
binaries-cross:
|
||||||
EXPORT_LOCAL=cross-out ./hack/cross
|
$(BUILDX_CMD) bake binaries-cross
|
||||||
|
|
||||||
cross:
|
|
||||||
./hack/cross
|
|
||||||
|
|
||||||
install: binaries
|
install: binaries
|
||||||
mkdir -p ~/.docker/cli-plugins
|
mkdir -p ~/.docker/cli-plugins
|
||||||
install bin/buildx ~/.docker/cli-plugins/docker-buildx
|
install bin/buildx ~/.docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
lint:
|
release:
|
||||||
./hack/lint
|
./hack/release
|
||||||
|
|
||||||
test:
|
|
||||||
./hack/test
|
|
||||||
|
|
||||||
validate-vendor:
|
|
||||||
./hack/validate-vendor
|
|
||||||
|
|
||||||
validate-docs:
|
|
||||||
./hack/validate-docs
|
|
||||||
|
|
||||||
validate-all: lint test validate-vendor validate-docs
|
validate-all: lint test validate-vendor validate-docs
|
||||||
|
|
||||||
|
lint:
|
||||||
|
$(BUILDX_CMD) bake lint
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(BUILDX_CMD) bake test
|
||||||
|
|
||||||
|
validate-vendor:
|
||||||
|
$(BUILDX_CMD) bake validate-vendor
|
||||||
|
|
||||||
|
validate-docs:
|
||||||
|
$(BUILDX_CMD) bake validate-docs
|
||||||
|
|
||||||
|
validate-authors:
|
||||||
|
$(BUILDX_CMD) bake validate-authors
|
||||||
|
|
||||||
vendor:
|
vendor:
|
||||||
./hack/update-vendor
|
./hack/update-vendor
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
./hack/update-docs
|
./hack/update-docs
|
||||||
|
|
||||||
generate-authors:
|
authors:
|
||||||
./hack/generate-authors
|
$(BUILDX_CMD) bake update-authors
|
||||||
|
|
||||||
.PHONY: vendor lint shell binaries install binaries-cross validate-all generate-authors validate-docs docs
|
.PHONY: shell binaries binaries-cross install release validate-all lint validate-vendor validate-docs validate-authors vendor docs authors
|
||||||
|
22
README.md
22
README.md
@ -26,8 +26,6 @@ Key features:
|
|||||||
- [From `Dockerfile`](#from-dockerfile)
|
- [From `Dockerfile`](#from-dockerfile)
|
||||||
- [Set buildx as the default builder](#set-buildx-as-the-default-builder)
|
- [Set buildx as the default builder](#set-buildx-as-the-default-builder)
|
||||||
- [Building](#building)
|
- [Building](#building)
|
||||||
- [with Docker 18.09+](#with-docker-1809)
|
|
||||||
- [with buildx or Docker 19.03](#with-buildx-or-docker-1903)
|
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [Building with buildx](#building-with-buildx)
|
- [Building with buildx](#building-with-buildx)
|
||||||
- [Working with builder instances](#working-with-builder-instances)
|
- [Working with builder instances](#working-with-builder-instances)
|
||||||
@ -90,25 +88,25 @@ RUN docker buildx version
|
|||||||
# Set buildx as the default builder
|
# Set buildx as the default builder
|
||||||
|
|
||||||
Running the command [`docker buildx install`](docs/reference/buildx_install.md)
|
Running the command [`docker buildx install`](docs/reference/buildx_install.md)
|
||||||
sets up docker builder command as an alias to `docker buildx`. This results in
|
sets up docker builder command as an alias to `docker buildx build`. This
|
||||||
the ability to have `docker build` use the current buildx builder.
|
results in the ability to have `docker build` use the current buildx builder.
|
||||||
|
|
||||||
To remove this alias, run [`docker buildx uninstall`](docs/reference/buildx_uninstall.md).
|
To remove this alias, run [`docker buildx uninstall`](docs/reference/buildx_uninstall.md).
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
## With buildx or Docker 19.03+
|
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ export DOCKER_BUILDKIT=1
|
# Buildx 0.6+
|
||||||
$ docker build --platform=local -o . git://github.com/docker/buildx
|
$ docker buildx bake "git://github.com/docker/buildx"
|
||||||
|
$ mkdir -p ~/.docker/cli-plugins
|
||||||
|
$ mv ./bin/buildx ~/.docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
# Docker 19.03+
|
||||||
|
$ DOCKER_BUILDKIT=1 docker build --platform=local -o . "git://github.com/docker/buildx"
|
||||||
$ mkdir -p ~/.docker/cli-plugins
|
$ mkdir -p ~/.docker/cli-plugins
|
||||||
$ mv buildx ~/.docker/cli-plugins/docker-buildx
|
$ mv buildx ~/.docker/cli-plugins/docker-buildx
|
||||||
```
|
|
||||||
|
|
||||||
## With Docker 18.09+
|
# Local
|
||||||
|
|
||||||
```console
|
|
||||||
$ git clone git://github.com/docker/buildx && cd buildx
|
$ git clone git://github.com/docker/buildx && cd buildx
|
||||||
$ make install
|
$ make install
|
||||||
```
|
```
|
||||||
|
128
docker-bake.hcl
Normal file
128
docker-bake.hcl
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
variable "GO_VERSION" {
|
||||||
|
default = "1.17.0"
|
||||||
|
}
|
||||||
|
variable "BIN_OUT" {
|
||||||
|
default = "./bin"
|
||||||
|
}
|
||||||
|
variable "RELEASE_OUT" {
|
||||||
|
default = "./release-out"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special target: https://github.com/docker/metadata-action#bake-definition
|
||||||
|
target "meta-helper" {
|
||||||
|
tags = ["docker/buildx-bin:local"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "_common" {
|
||||||
|
args = {
|
||||||
|
GO_VERSION = GO_VERSION
|
||||||
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["binaries"]
|
||||||
|
}
|
||||||
|
|
||||||
|
group "validate" {
|
||||||
|
targets = ["lint", "validate-vendor", "validate-docs"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "lint" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-vendor" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-docs" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/docs.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-authors" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/authors.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "update-vendor" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "update-docs" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/docs.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["./docs/reference"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "update-authors" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
dockerfile = "./hack/dockerfiles/authors.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "test" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
target = "test-coverage"
|
||||||
|
output = ["./coverage"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "binaries" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
target = "binaries"
|
||||||
|
output = [BIN_OUT]
|
||||||
|
platforms = ["local"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "binaries-cross" {
|
||||||
|
inherits = ["binaries"]
|
||||||
|
platforms = [
|
||||||
|
"darwin/amd64",
|
||||||
|
"darwin/arm64",
|
||||||
|
"linux/amd64",
|
||||||
|
"linux/arm/v6",
|
||||||
|
"linux/arm/v7",
|
||||||
|
"linux/arm64",
|
||||||
|
"linux/ppc64le",
|
||||||
|
"linux/riscv64",
|
||||||
|
"linux/s390x",
|
||||||
|
"windows/amd64",
|
||||||
|
"windows/arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "release" {
|
||||||
|
inherits = ["binaries-cross"]
|
||||||
|
target = "release"
|
||||||
|
output = [RELEASE_OUT]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "image" {
|
||||||
|
inherits = ["meta-helper", "binaries"]
|
||||||
|
output = ["type=image"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "image-cross" {
|
||||||
|
inherits = ["meta-helper", "binaries-cross"]
|
||||||
|
output = ["type=image"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "image-local" {
|
||||||
|
inherits = ["image"]
|
||||||
|
output = ["type=docker"]
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
: ${TARGETPLATFORM=$CLI_PLATFORM}
|
|
||||||
|
|
||||||
platformFlag=""
|
|
||||||
if [ -n "$TARGETPLATFORM" ]; then
|
|
||||||
platformFlag="--platform $TARGETPLATFORM"
|
|
||||||
fi
|
|
||||||
|
|
||||||
buildxCmd build $platformFlag \
|
|
||||||
--target "binaries" \
|
|
||||||
--output "type=local,dest=./bin/" \
|
|
||||||
.
|
|
@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
TYP=$1
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -e
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "usage: ./hack/build_ci_first_pass <binaries>"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$TYP" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
importCacheFlags=""
|
|
||||||
exportCacheFlags=""
|
|
||||||
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
||||||
if [ -n "$cacheRefFrom" ]; then
|
|
||||||
importCacheFlags="--cache-from=type=local,src=$cacheRefFrom"
|
|
||||||
fi
|
|
||||||
if [ -n "$cacheRefTo" ]; then
|
|
||||||
exportCacheFlags="--cache-to=type=local,dest=$cacheRefTo"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $TYP in
|
|
||||||
"binaries")
|
|
||||||
buildxCmd build $importCacheFlags $exportCacheFlags \
|
|
||||||
--target "binaries" \
|
|
||||||
$currentcontext
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo >&2 "Unknown type $TYP"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
24
hack/cross
24
hack/cross
@ -1,24 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -e
|
|
||||||
|
|
||||||
: ${TARGETPLATFORM=linux/amd64,linux/arm/v7,linux/arm64,darwin/amd64,windows/amd64,linux/ppc64le,linux/s390x,linux/riscv64}
|
|
||||||
: ${EXPORT_LOCAL=}
|
|
||||||
|
|
||||||
importCacheFlags=""
|
|
||||||
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
||||||
if [ -n "$cacheRefFrom" ]; then
|
|
||||||
importCacheFlags="--cache-from=type=local,src=$cacheRefFrom"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exportFlag=""
|
|
||||||
if [ -n "$EXPORT_LOCAL" ]; then
|
|
||||||
exportFlag="--output=type=local,dest=$EXPORT_LOCAL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
buildxCmd build $importCacheFlags $exportFlag \
|
|
||||||
--target "binaries" \
|
|
||||||
--platform "$TARGETPLATFORM" \
|
|
||||||
$currentcontext
|
|
@ -13,7 +13,3 @@ else
|
|||||||
( $dockerdCmd &>/var/log/dockerd.log & )
|
( $dockerdCmd &>/var/log/dockerd.log & )
|
||||||
exec ash
|
exec ash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
33
hack/dockerfiles/authors.Dockerfile
Normal file
33
hack/dockerfiles/authors.Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# syntax=docker/dockerfile:1.3-labs
|
||||||
|
|
||||||
|
FROM alpine:3.14 AS gen
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
RUN --mount=type=bind,target=. <<EOT
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
mkdir /out
|
||||||
|
# see also ".mailmap" for how email addresses and names are deduplicated
|
||||||
|
{
|
||||||
|
echo "# This file lists all individuals having contributed content to the repository."
|
||||||
|
echo "# For how it is generated, see hack/dockerfiles/authors.Dockerfile."
|
||||||
|
echo
|
||||||
|
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
|
||||||
|
} > /out/AUTHORS
|
||||||
|
cat /out/AUTHORS
|
||||||
|
EOT
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=gen /out /
|
||||||
|
|
||||||
|
FROM gen AS validate
|
||||||
|
RUN --mount=type=bind,target=.,rw <<EOT
|
||||||
|
set -e
|
||||||
|
git add -A
|
||||||
|
cp -rf /out/* .
|
||||||
|
if [ -n "$(git status --porcelain -- AUTHORS)" ]; then
|
||||||
|
echo >&2 'ERROR: Authors result differs. Please update with "make authors"'
|
||||||
|
git status --porcelain -- AUTHORS
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOT
|
@ -1,4 +1,4 @@
|
|||||||
# syntax=docker/dockerfile:1.3
|
# syntax=docker/dockerfile:1.3-labs
|
||||||
|
|
||||||
ARG GO_VERSION=1.17.0
|
ARG GO_VERSION=1.17.0
|
||||||
|
|
||||||
@ -13,19 +13,28 @@ RUN apk add --no-cache rsync git
|
|||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY --from=docsgen /out/docsgen /usr/bin
|
COPY --from=docsgen /out/docsgen /usr/bin
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs,readwrite \
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
rsync -a /context/. . && \
|
set -e
|
||||||
docsgen && \
|
rsync -a /context/. .
|
||||||
mkdir /out && cp -r docs/reference /out
|
docsgen
|
||||||
|
mkdir /out
|
||||||
|
cp -r docs/reference /out
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM scratch AS update
|
FROM scratch AS update
|
||||||
COPY --from=gen /out /out
|
COPY --from=gen /out /out
|
||||||
|
|
||||||
FROM gen AS validate
|
FROM gen AS validate
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs,readwrite \
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
rsync -a /context/. . && \
|
set -e
|
||||||
git add -A && \
|
rsync -a /context/. .
|
||||||
rm -rf docs/reference/* && \
|
git add -A
|
||||||
cp -rf /out/* ./docs/ && \
|
rm -rf docs/reference/*
|
||||||
./hack/validate-docs check
|
cp -rf /out/* ./docs/
|
||||||
|
if [ -n "$(git status --porcelain -- docs/reference)" ]; then
|
||||||
|
echo >&2 'ERROR: Docs result differs. Please update with "make docs"'
|
||||||
|
git status --porcelain -- docs/reference
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# syntax=docker/dockerfile:1.3
|
# syntax=docker/dockerfile:1.3-labs
|
||||||
|
|
||||||
ARG GO_VERSION=1.17.0
|
ARG GO_VERSION=1.17.0
|
||||||
|
|
||||||
@ -6,20 +6,30 @@ FROM golang:${GO_VERSION}-alpine AS vendored
|
|||||||
RUN apk add --no-cache git rsync
|
RUN apk add --no-cache git rsync
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs,readwrite \
|
--mount=target=.,type=tmpfs \
|
||||||
--mount=target=/go/pkg/mod,type=cache \
|
--mount=target=/go/pkg/mod,type=cache <<EOT
|
||||||
rsync -a /context/. . && \
|
set -e
|
||||||
go mod tidy && go mod vendor && \
|
rsync -a /context/. .
|
||||||
mkdir /out && cp -r go.mod go.sum vendor /out
|
go mod tidy
|
||||||
|
go mod vendor
|
||||||
|
mkdir /out
|
||||||
|
cp -r go.mod go.sum vendor /out
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM scratch AS update
|
FROM scratch AS update
|
||||||
COPY --from=vendored /out /out
|
COPY --from=vendored /out /out
|
||||||
|
|
||||||
FROM vendored AS validate
|
FROM vendored AS validate
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs,readwrite \
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
rsync -a /context/. . && \
|
set -e
|
||||||
git add -A && \
|
rsync -a /context/. .
|
||||||
rm -rf vendor && \
|
git add -A
|
||||||
cp -rf /out/* . && \
|
rm -rf vendor
|
||||||
./hack/validate-vendor check
|
cp -rf /out/* .
|
||||||
|
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
|
||||||
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
|
||||||
|
git status --porcelain -- go.mod go.sum vendor
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eu -o pipefail -x
|
|
||||||
|
|
||||||
if [ -x "$(command -v greadlink)" ]; then
|
|
||||||
# on macOS, GNU readlink is ava (greadlink) can be installed through brew install coreutils
|
|
||||||
cd "$(dirname "$(greadlink -f "$BASH_SOURCE")")/.."
|
|
||||||
else
|
|
||||||
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# see also ".mailmap" for how email addresses and names are deduplicated
|
|
||||||
|
|
||||||
{
|
|
||||||
cat <<-'EOH'
|
|
||||||
# This file lists all individuals having contributed content to the repository.
|
|
||||||
# For how it is generated, see `scripts/generate-authors.sh`.
|
|
||||||
EOH
|
|
||||||
echo
|
|
||||||
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
|
|
||||||
} > AUTHORS
|
|
@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
buildxCmd build --file ./hack/dockerfiles/lint.Dockerfile .
|
|
35
hack/release
35
hack/release
@ -1,37 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
OUT=${1:-release-out}
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
: ${PLATFORMS=linux/amd64}
|
: ${BUILDX_CMD=docker buildx}
|
||||||
: ${CHECKSUMS=}
|
: ${RELEASE_OUT=./release-out}
|
||||||
|
|
||||||
importCacheFlags=""
|
# release
|
||||||
if [[ -n "$cacheRefFrom" ]] && [[ "$cacheType" = "local" ]]; then
|
(set -x ; ${BUILDX_CMD} bake --set "*.output=$RELEASE_OUT" release)
|
||||||
for ref in $cacheRefFrom; do
|
|
||||||
importCacheFlags="$importCacheFlags--cache-from=type=local,src=$ref "
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
buildxCmd build $importCacheFlags \
|
|
||||||
--target "release" \
|
|
||||||
--platform "$PLATFORMS" \
|
|
||||||
--output "type=local,dest=$OUT" \
|
|
||||||
$currentcontext
|
|
||||||
|
|
||||||
# wrap binaries
|
# wrap binaries
|
||||||
{ set +x; } 2>/dev/null
|
mv -f ./${RELEASE_OUT}/**/* ./${RELEASE_OUT}/
|
||||||
if [[ $PLATFORMS =~ "," ]]; then
|
find ./${RELEASE_OUT} -type d -empty -delete
|
||||||
mv -f ./$OUT/**/* ./$OUT/
|
|
||||||
find ./$OUT -type d -empty -delete
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$CHECKSUMS" ]; then
|
# checksums
|
||||||
if ! type shasum > /dev/null 2>&1; then
|
if ! type shasum > /dev/null 2>&1; then
|
||||||
echo >&2 "ERROR: shasum is required"
|
echo >&2 "ERROR: shasum is required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
find ./$OUT/ -type f \( -iname "buildx-*" ! -iname "*darwin*" \) -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# .*/# #' > ./$OUT/checksums.txt
|
|
||||||
fi
|
fi
|
||||||
|
find ./${RELEASE_OUT}/ -type f \( -iname "buildx-*" ! -iname "*darwin*" \) -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# .*/# #' > ./${RELEASE_OUT}/checksums.txt
|
||||||
|
@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
: ${BUILDX_CMD=docker buildx}
|
||||||
: ${TMUX=}
|
: ${TMUX=}
|
||||||
|
|
||||||
function clean {
|
function clean {
|
||||||
docker rmi $(cat $iidfile)
|
docker rmi $iid
|
||||||
}
|
}
|
||||||
|
|
||||||
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
iid=buildx-shell
|
||||||
DOCKER_BUILDKIT=1 docker build --iidfile $iidfile --target demo-env .
|
(set -x ; ${BUILDX_CMD} build --output "type=docker,name=$iid" --target shell .)
|
||||||
trap clean EXIT
|
trap clean EXIT
|
||||||
SSH=
|
SSH=
|
||||||
if [ -n "$MOUNT_SSH_AUTH_SOCK" ]; then
|
if [ -n "$MOUNT_SSH_AUTH_SOCK" ]; then
|
||||||
SSH="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"
|
SSH="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"
|
||||||
fi
|
fi
|
||||||
docker run $SSH -it --privileged --rm -e TMUX_ENTRYPOINT=$TMUX $(cat $iidfile)
|
docker run $SSH -it --privileged --rm -e TMUX_ENTRYPOINT=$TMUX $iid
|
||||||
|
47
hack/test
47
hack/test
@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
. $(dirname $0)/util
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
: ${BUILDX_NOCACHE=}
|
|
||||||
: ${TEST_COVERAGE=}
|
|
||||||
|
|
||||||
importCacheFlags=""
|
|
||||||
if [ -n "$cacheRefFrom" ]; then
|
|
||||||
if [ "$cacheType" = "local" ]; then
|
|
||||||
for ref in $cacheRefFrom; do
|
|
||||||
importCacheFlags="$importCacheFlags--cache-from=type=local,src=$ref "
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
iid="buildx-tests"
|
|
||||||
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
|
||||||
|
|
||||||
coverageVol=""
|
|
||||||
coverageFlags=""
|
|
||||||
if [ "$TEST_COVERAGE" = "1" ]; then
|
|
||||||
covdir="$(pwd)/coverage"
|
|
||||||
mkdir -p "$covdir"
|
|
||||||
coverageVol="-v $covdir:/coverage"
|
|
||||||
coverageFlags="-coverprofile=/coverage/coverage.txt -covermode=atomic"
|
|
||||||
fi
|
|
||||||
|
|
||||||
buildxCmd build $importCacheFlags \
|
|
||||||
--target "integration-tests" \
|
|
||||||
--output "type=docker,name=$iid" \
|
|
||||||
$currentcontext
|
|
||||||
|
|
||||||
cacheVolume="buildx-cache"
|
|
||||||
if ! docker inspect "$cacheVolume" > /dev/null 2>&1; then
|
|
||||||
cacheVolume=$(docker create --name=buildx-cache -v /root/.cache -v /go/pkg/mod alpine)
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker run --rm -v /tmp $coverageVol --volumes-from=$cacheVolume --privileged $iid go test $coverageFlags ${TESTFLAGS:--v} ${TESTPKGS:-./...}
|
|
||||||
|
|
||||||
if [ -n "$BUILDX_NOCACHE" ]; then
|
|
||||||
docker rm -v $cacheVolume
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm "$iidfile"
|
|
||||||
docker rmi $iid
|
|
@ -1,16 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. $(dirname $0)/util
|
set -eu -o pipefail
|
||||||
set -eu
|
|
||||||
|
: ${BUILDX_CMD=docker buildx}
|
||||||
|
|
||||||
output=$(mktemp -d -t buildx-output.XXXXXXXXXX)
|
output=$(mktemp -d -t buildx-output.XXXXXXXXXX)
|
||||||
|
(set -x ; ${BUILDX_CMD} bake --set "*.output=$output" update-docs)
|
||||||
buildxCmd build \
|
|
||||||
--target "update" \
|
|
||||||
--output "type=local,dest=$output" \
|
|
||||||
--file "./hack/dockerfiles/docs.Dockerfile" \
|
|
||||||
.
|
|
||||||
|
|
||||||
rm -rf ./docs/reference/*
|
rm -rf ./docs/reference/*
|
||||||
cp -R "$output"/out/* ./docs/
|
cp -R "$output"/out/* ./docs/
|
||||||
rm -rf $output
|
rm -rf $output
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. $(dirname $0)/util
|
set -eu -o pipefail
|
||||||
set -eu
|
|
||||||
|
: ${BUILDX_CMD=docker buildx}
|
||||||
|
|
||||||
output=$(mktemp -d -t buildx-output.XXXXXXXXXX)
|
output=$(mktemp -d -t buildx-output.XXXXXXXXXX)
|
||||||
|
(set -x ; ${BUILDX_CMD} bake --set "*.output=$output" update-vendor)
|
||||||
buildxCmd build \
|
|
||||||
--target "update" \
|
|
||||||
--output "type=local,dest=$output" \
|
|
||||||
--file "./hack/dockerfiles/vendor.Dockerfile" \
|
|
||||||
.
|
|
||||||
|
|
||||||
rm -rf ./vendor
|
rm -rf ./vendor
|
||||||
cp -R "$output"/out/* .
|
cp -R "$output"/out/* .
|
||||||
rm -rf $output
|
rm -rf $output
|
||||||
|
66
hack/util
66
hack/util
@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
: ${CI=}
|
|
||||||
: ${PREFER_BUILDCTL=}
|
|
||||||
: ${PREFER_LEGACY=}
|
|
||||||
: ${CLI_PLATFORM=}
|
|
||||||
: ${GITHUB_ACTIONS=}
|
|
||||||
: ${CACHEDIR_FROM=}
|
|
||||||
: ${CACHEDIR_TO=}
|
|
||||||
|
|
||||||
if [ "$PREFER_BUILDCTL" = "1" ]; then
|
|
||||||
echo >&2 "WARNING: PREFER_BUILDCTL is no longer supported. Ignoring."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PREFER_LEGACY" = "1" ]; then
|
|
||||||
echo >&2 "WARNING: PREFER_LEGACY is no longer supported. Ignoring."
|
|
||||||
fi
|
|
||||||
|
|
||||||
progressFlag=""
|
|
||||||
if [ "$CI" = "true" ]; then
|
|
||||||
progressFlag="--progress=plain"
|
|
||||||
fi
|
|
||||||
|
|
||||||
buildxCmd() {
|
|
||||||
if docker buildx version >/dev/null 2>&1; then
|
|
||||||
set -x
|
|
||||||
docker buildx "$@" $progressFlag
|
|
||||||
elif buildx version >/dev/null 2>&1; then
|
|
||||||
set -x
|
|
||||||
buildx "$@" $progressFlag
|
|
||||||
elif docker version >/dev/null 2>&1; then
|
|
||||||
set -x
|
|
||||||
DOCKER_BUILDKIT=1 docker "$@" $progressFlag
|
|
||||||
else
|
|
||||||
echo >&2 "ERROR: Please enable DOCKER_BUILDKIT or install standalone buildx"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$CLI_PLATFORM" ]; then
|
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
|
||||||
arch="$(uname -m)"
|
|
||||||
if [ "$arch" = "x86_64" ]; then
|
|
||||||
arch="amd64"
|
|
||||||
fi
|
|
||||||
CLI_PLATFORM="darwin/$arch"
|
|
||||||
elif uname -s | grep MINGW > /dev/null 2>&1 ; then
|
|
||||||
CLI_PLATFORM="windows/amd64"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cacheType=""
|
|
||||||
cacheRefFrom=""
|
|
||||||
cacheRefTo=""
|
|
||||||
currentref=""
|
|
||||||
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
||||||
currentref="git://github.com/$GITHUB_REPOSITORY#$GITHUB_REF"
|
|
||||||
cacheType="local"
|
|
||||||
cacheRefFrom="$CACHEDIR_FROM"
|
|
||||||
cacheRefTo="$CACHEDIR_TO"
|
|
||||||
fi
|
|
||||||
|
|
||||||
currentcontext="."
|
|
||||||
if [ -n "$currentref" ]; then
|
|
||||||
currentcontext="--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 $currentref"
|
|
||||||
fi
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
case ${1:-} in
|
|
||||||
'')
|
|
||||||
. $(dirname $0)/util
|
|
||||||
buildxCmd build \
|
|
||||||
--target validate \
|
|
||||||
--file ./hack/dockerfiles/docs.Dockerfile \
|
|
||||||
.
|
|
||||||
;;
|
|
||||||
check)
|
|
||||||
status="$(git status --porcelain -- docs/reference 2>/dev/null)"
|
|
||||||
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
|
|
||||||
if [ "$diffs" ]; then
|
|
||||||
{
|
|
||||||
set +x
|
|
||||||
echo 'The result of ./hack/update-docs differs'
|
|
||||||
echo
|
|
||||||
echo "$diffs"
|
|
||||||
echo
|
|
||||||
echo 'Please vendor your package with ./hack/update-docs'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo 'Congratulations! All docs changes are done the right way.'
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
case ${1:-} in
|
|
||||||
'')
|
|
||||||
. $(dirname $0)/util
|
|
||||||
buildxCmd build \
|
|
||||||
--target validate \
|
|
||||||
--file ./hack/dockerfiles/vendor.Dockerfile \
|
|
||||||
.
|
|
||||||
;;
|
|
||||||
check)
|
|
||||||
status="$(git status --porcelain -- go.mod go.sum vendor 2>/dev/null)"
|
|
||||||
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
|
|
||||||
if [ "$diffs" ]; then
|
|
||||||
{
|
|
||||||
set +x
|
|
||||||
echo 'The result of "make vendor" differs'
|
|
||||||
echo
|
|
||||||
echo "$diffs"
|
|
||||||
echo
|
|
||||||
echo 'Please vendor your package with "make vendor"'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo 'Congratulations! All vendoring changes are done the right way.'
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
x
Reference in New Issue
Block a user