From e0adf389bb7fdf45e986449465e74c9e3310fbed Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Thu, 25 Jul 2024 10:17:05 +0300 Subject: [PATCH] Try publishing static binaries as distroless containers Signed-off-by: Vasyl Gello --- .github/workflows/trunk.yml | 35 +++++++++++++++++++++++++++++++---- Dockerfile.static | 9 +++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.static diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 90c33e8..d4105b1 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -100,6 +100,7 @@ jobs: # echo "::group::yggstack-linux-i386-static" CGO_ENABLED=0 GOOS=linux GOARCH=386 ./build -s -o yggstack-linux-i386-static + CGO_ENABLED=0 GOOS=linux GOARCH=386 ./build -s -o yggstack-linux-386-static ldd yggstack-linux-i386-static || echo "OK" echo "::endgroup::" # @@ -143,13 +144,13 @@ jobs: ldd yggstack-linux-mips64le-static || echo "OK" echo "::endgroup::" # - echo "::group::yggstack-linux-ppc64" - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 ./build -s -o yggstack-linux-ppc64 + echo "::group::yggstack-linux-ppc64-static" + CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 ./build -s -o yggstack-linux-ppc64-static ldd yggstack-linux-ppc64-static || echo "OK" echo "::endgroup::" # - echo "::group::yggstack-linux-ppc64le" - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le ./build -s -o yggstack-linux-ppc64le + echo "::group::yggstack-linux-ppc64le-static" + CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le ./build -s -o yggstack-linux-ppc64le-static ldd yggstack-linux-ppc64le-static || echo "OK" echo "::endgroup::" # @@ -260,3 +261,29 @@ jobs: gh release create trunk --prerelease yggstack-* || gh release upload trunk yggstack-* --clobber env: GH_TOKEN: ${{ github.token }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push yggstack container image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile.static + platforms: + - linux/386 + - linux/amd64 + - linux/arm/v6 + - linux/arm/v7 + - linux/arm64 + - linux/ppc64le + - linux/riscv64 + - linux/s390x + push: true + tags: yggdrasil-network/yggstack:trunk diff --git a/Dockerfile.static b/Dockerfile.static new file mode 100644 index 0000000..74ad649 --- /dev/null +++ b/Dockerfile.static @@ -0,0 +1,9 @@ +FROM gcr.io/distroless/static + +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + +COPY --chown=0:0 --chmod=0755 yggstack-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}-static /bin/yggstack + +ENTRYPOINT [ "/bin/yggstack" ]