From 75db7b6066f554e91a3475dd07443a493ed64b55 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Sat, 11 Jan 2025 23:07:12 +0100 Subject: [PATCH] Build container with all tools on alpine --- .../workflows/build-sign-commit-images.yaml | 26 +++++++++++++++++++ Dockerfile.alltools | 21 +++++---------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-sign-commit-images.yaml b/.github/workflows/build-sign-commit-images.yaml index 9374a9d21b..fd8962150e 100644 --- a/.github/workflows/build-sign-commit-images.yaml +++ b/.github/workflows/build-sign-commit-images.yaml @@ -33,6 +33,32 @@ jobs: push: ${{ fromJSON(true) }} trivy: ${{ fromJSON(true) }} + build-container-geth-all-sha: + runs-on: [self-hosted, blockchain, 8-cpu] + permissions: + contents: read + id-token: write + security-events: write + steps: + - uses: actions/checkout@v4 + - name: Login at GCP Artifact Registry + uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@v2.0 + with: + workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-celo-blockchain/providers/github-by-repos' + service-account: 'celo-blockchain@devopsre.iam.gserviceaccount.com' + docker-gcp-registries: us-west1-docker.pkg.dev + - name: Build and push container + uses: celo-org/reusable-workflows/.github/actions/build-container@v2.0 + with: + platforms: linux/amd64 + registry: us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/geth-all + tags: ${{ github.sha }} + context: . + dockerfile: Dockerfile.alltools + push: ${{ fromJSON(true) }} + trivy: ${{ fromJSON(true) }} + + build-container-geth-master: runs-on: [self-hosted, blockchain, 8-cpu] if: github.ref == 'refs/heads/master' diff --git a/Dockerfile.alltools b/Dockerfile.alltools index e49b022494..4a6d0291a2 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -1,25 +1,19 @@ # Build Geth in a stock Go builder container -FROM golang:1.19-bookworm as builder +FROM golang:1.19-alpine as builder -RUN headers_package="linux-headers-$(dpkg --print-architecture)" && \ - apt update && \ - apt install -y build-essential git musl-dev $headers_package +RUN apk add --no-cache make gcc musl-dev linux-headers git ADD . /go-ethereum RUN cd /go-ethereum && make all-musl -# Pull all binaries into a second stage deploy alpine container -FROM debian:bookworm +# Pull Geth into a second stage deploy alpine container +FROM alpine:latest ARG COMMIT_SHA -RUN apt update &&\ - apt install -y ca-certificates wget &&\ - rm -rf /var/cache/apt &&\ - rm -rf /var/lib/apt/lists/* &&\ - ln -sf /bin/bash /bin/sh - +RUN apk add --no-cache ca-certificates COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/ RUN echo $COMMIT_SHA > /version.txt +ADD scripts/run_geth_in_docker.sh / EXPOSE 8545 8546 30303 30303/udp @@ -28,5 +22,4 @@ ARG COMMIT="" ARG VERSION="" ARG BUILDNUM="" -LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM" - +LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM" \ No newline at end of file