From 3c63d6309e7c3accee69db8c443c581f92f28114 Mon Sep 17 00:00:00 2001 From: 2xburnt <169301814+2xburnt@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:37:55 -0500 Subject: [PATCH] add goreleaser to base dockerfile --- .github/workflows/build.yml | 22 +++++++++++++++++--- Dockerfile | 41 ------------------------------------- 2 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f912f0..af232aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,9 +60,15 @@ jobs: type=raw,value=latest,enable={{is_default_branch}} - name: Setup env - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: /home/runner/_work/goreleaser-cross/goreleaser-cross/.env + run: | + cat /home/runner/_work/goreleaser-cross/goreleaser-cross/.env >> ${GITHUB_ENV} + + - name: Add to dockerfile + working-directory: /home/runner/_work/goreleaser-cross/goreleaser-cross + run: | + echo "FROM ghcr.io/goreleaser/goreleaser$GORELEASER_DISTRIBUTION:v$GORELEASER_VERSION$GORELEASER_DISTRIBUTION as goreleaser >> Dockerfile.base + echo "FROM ghcr.io/goreleaser/goreleaser-cross-base:$TAG_VERSION" >> Dockerfile.base + echo "COPY --from=goreleaser /usr/bin/goreleaser /usr/bin/goreleaser" >> Dockerfile.base - name: Build and push by digest id: build @@ -75,6 +81,16 @@ jobs: labels: ${{ steps.meta.outputs.labels }} platforms: ${{ matrix.os }}/${{ matrix.arch }} outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true + build-args: | + TAG_VERSION=${{ env.TAG_VERSION }} + GORELEASER_VERSION=${{ env.GORELEASER_VERSION }} + DEBIAN_FRONTEND=${{ env.DEBIAN_FRONTEND }} + GO_VERSION=${{ env.GO_VERSION }} + TINI_VERSION=${{ env.TINI_VERSION }} + COSIGN_VERSION=${{ env.COSIGN_VERSION }} + COSIGN_SHA256=${{ env.COSIGN_SHA256 }} + DEBIAN_FRONTEND=${{ env.DEBIAN_FRONTEND }} + TOOLCHAINS_VERSION=${{ env.TOOLCHAINS_VERSION }} - name: Export digest id: digest diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 72ca6d2..0000000 --- a/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -ARG GORELEASER_VERSION=v1.22.7 - -FROM goreleaser/goreleaser-cross:${GORELEASER_VERSION} AS builder - -# Install build dependencies -RUN apt-get update \ - && apt-get install --no-install-recommends -y -q \ - zlib1g-dev \ - libmpc-dev \ - libmpfr-dev \ - libgmp-dev \ - libxml2-dev \ - libssl-dev - -ENV OSX_CROSS_PATH=/usr/local/osxcross - -# Build osxcross -# See https://github.com/tpoechtrager/osxcross/blob/master/build.sh#L31-L49 for SDK overview. -RUN rm -rf ${OSX_CROSS_PATH} \ - && git clone https://github.com/tpoechtrager/osxcross ${OSX_CROSS_PATH} \ - && cd ${OSX_CROSS_PATH} \ - # Don't change file name when downloading because osxcross auto-detects the version from the name - && wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz -P tarballs \ - && UNATTENDED=yes OSX_VERSION_MIN=10.15 ./build.sh \ - # Cleanups before Docker layer is finalized - && rm -r tarballs/ \ - && chmod +rx ${OSX_CROSS_PATH} \ - && chmod +rx ${OSX_CROSS_PATH}/target \ - && chmod -R +rx ${OSX_CROSS_PATH}/target/bin - -# RUN ls -l ${OSX_CROSS_PATH}/target/bin -RUN ${OSX_CROSS_PATH}/target/bin/x86_64-apple-darwin20.4-clang --version \ - && ${OSX_CROSS_PATH}/target/bin/aarch64-apple-darwin20.4-clang --version - -FROM scratch AS release -COPY --from=builder / / - -ENV OSX_CROSS_PATH=/usr/local/osxcross -ENV PATH=$PATH:${OSX_CROSS_PATH}/bin:/usr/local/go/bin - -ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]