From 17020d97fe1f15dc9c5a29d3b28628ff07ce26a7 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 20 Aug 2022 17:31:51 +0200 Subject: [PATCH 1/3] Dockerfile for cross compilation Signed-off-by: CrazyMax --- .dockerignore | 2 ++ .gitignore | 4 +-- Dockerfile | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ docker-bake.hcl | 31 +++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-bake.hcl diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..038672e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/bin +/release diff --git a/.gitignore b/.gitignore index c0f3701..038672e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -bin -release +/bin +/release diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2f6d503 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,80 @@ +# syntax=docker/dockerfile:1 + +ARG GO_VERSION=1.16.7 +ARG XX_VERSION=1.1.2 +ARG OSXCROSS_VERSION=11.3-r7-alpine + +ARG PKG=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}-alpine AS gobase +COPY --from=xx / / +RUN apk add --no-cache clang file git lld llvm pkgconf +ENV GOFLAGS="-mod=vendor" +ENV CGO_ENABLED="1" +WORKDIR /src + +FROM gobase AS version +ARG PKG +RUN --mount=target=. \ + VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags); \ + echo "-s -w -X ${PKG}/credentials.Version=${VERSION}" | tee /tmp/.ldflags; \ + echo -n "${VERSION}" | tee /tmp/.version; + +FROM gobase AS base +ARG TARGETPLATFORM +RUN xx-apk add musl-dev gcc libsecret-dev pass + +FROM base AS build-linux +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT +RUN --mount=type=bind,target=. \ + --mount=type=cache,target=/root/.cache \ + --mount=type=cache,target=/go/pkg/mod \ + --mount=type=bind,from=version,source=/tmp/.ldflags,target=/tmp/.ldflags < Date: Sun, 24 Jul 2022 18:00:29 +0200 Subject: [PATCH 2/3] Basic GHA workflow for cross compilation Signed-off-by: CrazyMax --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fd111c7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: build + +on: + workflow_dispatch: + push: + branches: + - 'master' + tags: + - 'v*' + pull_request: + +env: + DESTDIR: ./bin + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Build + uses: docker/bake-action@v2 + with: + targets: binaries + - + name: Move artifacts + run: | + mv ${{ env.DESTDIR }}/**/* ${{ env.DESTDIR }}/ + - + name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: docker-credential-helpers + path: ${{ env.DESTDIR }}/* + if-no-files-found: error From a251a3e4c5d7028a9f2278e1042a0534c1a854f4 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 8 May 2022 04:18:41 +0200 Subject: [PATCH 3/3] Remove unused Jenkinsfile Signed-off-by: CrazyMax --- Jenkinsfile | 83 ----------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index e43d232..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,83 +0,0 @@ -pipeline { - agent none - options { - checkoutToSubdirectory('src/github.com/docker/docker-credential-helpers') - } - stages { - stage('build') { - parallel { - stage('linux') { - agent { - kubernetes { - label 'declarative' - containerTemplate { - name 'golang' - image 'golang:1.12.4' - ttyEnabled true - command 'cat' - } - } - } - environment { - GOPATH = pwd() - PATH = "/usr/local/go/bin:${GOPATH}/bin:$PATH" - } - steps { - container('golang') { - dir('src/github.com/docker/docker-credential-helpers') { - sh 'apt-get update && apt-get install -y libsecret-1-dev pass' - sh 'make deps fmt lint test' - sh 'make pass secretservice' - sh 'make linuxrelease' - archiveArtifacts 'release/docker-credential-*' - } - } - } - } - stage('mac') { - agent { - label 'mac-build && go1.12.4' - } - environment { - PATH = "/usr/local/go/bin:${GOPATH}/bin:$PATH" - GOPATH = pwd() - } - steps { - dir('src/github.com/docker/docker-credential-helpers') { - sh 'make deps fmt lint test' - sh 'make osxcodesign' - sh 'make osxrelease' - archiveArtifacts 'release/docker-credential-*' - } - } - } - stage('windows') { - agent { - label 'win-build && go1.12.4' - } - environment { - GOPATH = pwd() - PATH = "${pwd()}/bin;$PATH" - PFX = credentials('windows-build-2019-pfx') - PFXPASSWORD = credentials('windows-build-2019-pfx-password') - } - steps { - dir('src/github.com/docker/docker-credential-helpers') { - sh 'echo ${PFX} | base64 -d > pfx' - - sh 'make deps fmt lint test' - sh 'make wincred' - bat """ "C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x86\\signtool.exe" sign /fd SHA256 /a /f pfx /p ${PFXPASSWORD} /d Docker /du https://www.docker.com /t http://timestamp.verisign.com/scripts/timestamp.dll bin\\docker-credential-wincred.exe """ - archiveArtifacts 'bin/docker-credential-*' - } - } - post { - always { - sh 'rm -f pfx' - } - } - } - } - } - } -}