From d8ac23f9082a879c259c5d6ff6a2544041f5adad Mon Sep 17 00:00:00 2001 From: unitexe Date: Thu, 26 Feb 2026 18:15:06 -0600 Subject: gRPCurl containers for amd64, arm64 & armv7 --- .github/workflows/ci.yml | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ Containerfile | 28 +++++++++++++++ README.md | 7 ++++ 3 files changed, 129 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Containerfile create mode 100644 README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e143248 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: gRPCCCurl Container +on: + workflow_dispatch: + +env: + IMAGE_NAME: grpcccurl + IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} + REGISTRY_USER: ${{ github.actor }} + REGISTRY_PASSWORD: ${{ github.token }} + + +jobs: + check-upstream: + name: Check upstream version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.upstream.outputs.version }} + should_build: ${{ steps.compare.outputs.should_build }} + + steps: + - name: Get latest upstream release + id: upstream + run: | + VERSION=$(curl -s https://api.github.com/repos/fullstorydev/grpcurl/releases/latest | jq -r '.tag_name' | sed 's/^v//') + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "Upstream version: ${VERSION}" + + - name: Check if version is already published + id: compare + run: | + UPSTREAM="${{ steps.upstream.outputs.version }}" + STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: Bearer ${{ github.token }}" \ + "https://ghcr.io/v2/${{ github.repository_owner }}/grpcccurl/manifests/${UPSTREAM}") + + if [[ "${STATUS}" == "200" ]]; then + echo "should_build=false" >> $GITHUB_OUTPUT + echo "Already published ${UPSTREAM}, skipping" + else + echo "should_build=true" >> $GITHUB_OUTPUT + echo "Version ${UPSTREAM} not yet published, will build" + fi + + build-and-push: + name: Build and push image + runs-on: ubuntu-latest + needs: check-upstream + if: needs.check-upstream.outputs.should_build == 'true' + + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Install QEMU dependency + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + + - name: Build image + id: build_image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: ${{ needs.check-upstream.outputs.version }} latest + archs: amd64, arm64, arm/v7 + build-args: | + VERSION=${{ needs.check-upstream.outputs.version }} + containerfiles: | + ./Containerfile + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.description=grpcccurl container (upstream fullstorydev/grpcurl) + org.opencontainers.image.licenses=MIT + org.opencontainers.image.version=${{ needs.check-upstream.outputs.version }} + + - name: Push to GHCR + uses: redhat-actions/push-to-registry@v2 + id: push + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Echo outputs + run: | + echo "${{ toJSON(steps.push.outputs) }}" diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..3e5cac2 --- /dev/null +++ b/Containerfile @@ -0,0 +1,28 @@ +# +# Build (fetch) stage +# + +FROM alpine AS fetch + +ARG TARGETARCH +ARG TARGETVARIANT +ARG VERSION + +RUN echo "TARGETARCH=${TARGETARCH} TARGETVARIANT=${TARGETVARIANT}" +RUN apk add --no-cache wget tar \ + && ARCH=$(uname -m) \ + && case "${ARCH}" in \ + x86_64) GRPC_ARCH="x86_64" ;; \ + aarch64) GRPC_ARCH="arm64" ;; \ + armv7l) GRPC_ARCH="armv7" ;; \ + esac \ + && wget -q https://github.com/fullstorydev/grpcurl/releases/download/v${VERSION}/grpcurl_${VERSION}_linux_${GRPC_ARCH}.tar.gz \ + && tar --no-same-owner -xzf grpcurl_${VERSION}_linux_${GRPC_ARCH}.tar.gz + +# +# Run stage +# + +FROM scratch +COPY --from=fetch /grpcurl /grpcurl +ENTRYPOINT ["/grpcurl"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..711fc23 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# grpcccurl +Containers for [grpcurl](https://github.com/fullstorydev/grpcurl) for the following platforms: +* amd64 +* arm64 +* arm/v7 + +Since an `arm/v7` container is not published upstream. -- cgit v1.2.3