From 1172ff42f9042b2915761f1adae93bc0952dd617 Mon Sep 17 00:00:00 2001 From: jesse snyder Date: Tue, 28 Mar 2023 16:59:33 -0600 Subject: [PATCH] containerize w/ github action to build and push to ghcr (#3) --- .../astria-build-and-publish-image.yml | 26 +++++++++++++ Dockerfile | 3 +- Dockerfile.alltools | 3 +- grpc/README.md | 39 +++++++++++++++++-- 4 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/astria-build-and-publish-image.yml diff --git a/.github/workflows/astria-build-and-publish-image.yml b/.github/workflows/astria-build-and-publish-image.yml new file mode 100644 index 000000000000..86f4ec936a66 --- /dev/null +++ b/.github/workflows/astria-build-and-publish-image.yml @@ -0,0 +1,26 @@ +build-and-publish-latest: +on: + push: + branches: + - astria # Running this job only for astria branch + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 # Checking out the repo + - uses: actions/setup-go@v4 + with: + go-version: "^1.20.x" # The Go version to download (if necessary) and use. + - run: go version + + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + # TODO - build for amd64 and arm64? + - name: Build and Publish latest Docker image + uses: TCPShield/gp-docker-action@1.1.13 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} # Provide GITHUB_TOKEN to login into the GitHub Packages + image-name: ghcr.io/astriaorg/go-ethereum # Provide only Docker image name, tag will be automatically set to latest + # Pass some additional arguments to the docker build command + # FIXME - version needs to be autoincrement, probably from git tags? + custom-args: --build-arg COMMIT=${GITHUB_SHA} --build-arg VERSION=0.1.0 --build-arg BUILDNUM=${GITHUB_RUN_NUMBER} diff --git a/Dockerfile b/Dockerfile index 1951fed8ef87..0b51035e3669 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,8 @@ FROM alpine:latest RUN apk add --no-cache ca-certificates COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/ -EXPOSE 8545 8546 30303 30303/udp +# Astria - add 50051 for GRPC +EXPOSE 8545 8546 30303 30303/udp 50051 ENTRYPOINT ["geth"] # Add some metadata labels to help programatic image consumption diff --git a/Dockerfile.alltools b/Dockerfile.alltools index 70ccc39825e9..598a45998f28 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -22,7 +22,8 @@ FROM alpine:latest RUN apk add --no-cache ca-certificates COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/ -EXPOSE 8545 8546 30303 30303/udp +# Astria - add 50051 for GRPC +EXPOSE 8545 8546 30303 30303/udp 50051 # Add some metadata labels to help programatic image consumption ARG COMMIT="" diff --git a/grpc/README.md b/grpc/README.md index a1736192082d..eb91757bc3db 100644 --- a/grpc/README.md +++ b/grpc/README.md @@ -1,6 +1,6 @@ This package provides a gRPC server as an entrypoint to the EVM. -Helpful commands (MacOS): +## Build and run from source: ```bash # install necessary dependencies brew install leveldb @@ -8,8 +8,39 @@ brew install leveldb # build geth make geth -# TODO - run beacon? - # run geth -./build/bin/geth --goerli --grpc --grpc.addr "[::1]" --grpc.port 50051 +./build/bin/geth --goerli --grpc --grpc.addr "0.0.0.0" --grpc.port 50051 +``` + +### Running with remote Docker image: +```bash +docker run --rm \ + -p 8545:8545 -p 30303:30303 -p 50051:50051 \ + ghcr.io/astriaorg/go-ethereum --goerli \ + --grpc --grpc.addr "0.0.0.0" --grpc.port 50051 +``` + +### Local Docker workflow: +```bash +# build local docker image +docker build \ + --build-arg COMMIT=$(git rev-parse HEAD) \ + --build-arg VERSION=0.1 \ + --build-arg BUILDNUM=1 \ + --tag ghcr.io/astriaorg/go-ethereum:local . + +# run local docker image +docker run --rm \ + -p 8545:8545 -p 30303:30303 -p 50051:50051 \ + ghcr.io/astriaorg/go-ethereum:local --goerli \ + --grpc --grpc.addr "0.0.0.0" --grpc.port 50051 + +# build and push to remote from local (as opposed to gh action) +docker build \ + --build-arg COMMIT=$(git rev-parse HEAD) \ + --build-arg VERSION=0.1 \ + --build-arg BUILDNUM=1 \ + --tag ghcr.io/astriaorg/go-ethereum:latest . +echo $CR_PAT | docker login ghcr.io -u astriaorg --password-stdin +docker push ghcr.io/astriaorg/go-ethereum:latest ```