From 25e34d9dfe15a24fe2cf384a59794bc8cd982788 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 28 Mar 2023 16:54:23 -0600 Subject: [PATCH 1/4] containerize w/ github action to build and push to ghcr --- .../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 ``` From 9ef3877ec9b3f0ca6f02a701ef0fb52f689903ad Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 28 Mar 2023 17:02:25 -0600 Subject: [PATCH 2/4] fix gh action yml syntax --- .github/workflows/astria-build-and-publish-image.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/astria-build-and-publish-image.yml b/.github/workflows/astria-build-and-publish-image.yml index 86f4ec936a66..d7e521546a87 100644 --- a/.github/workflows/astria-build-and-publish-image.yml +++ b/.github/workflows/astria-build-and-publish-image.yml @@ -1,15 +1,17 @@ -build-and-publish-latest: +name: Build and Publish Docker image on: push: branches: - astria # Running this job only for astria branch - runs-on: ubuntu-latest +jobs: + build-and-publish-latest: + 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. + go-version: "^1.20.x" # The Go version to download (if necessary) and use. - run: go version - name: Log in to registry From aa3932b17ec86c4e4ca49cf414ce1325481a3a9b Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 28 Mar 2023 17:11:48 -0600 Subject: [PATCH 3/4] enable manual trigger --- .github/workflows/astria-build-and-publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/astria-build-and-publish-image.yml b/.github/workflows/astria-build-and-publish-image.yml index d7e521546a87..58bfe6b82fe6 100644 --- a/.github/workflows/astria-build-and-publish-image.yml +++ b/.github/workflows/astria-build-and-publish-image.yml @@ -1,9 +1,9 @@ name: Build and Publish Docker image on: + workflow_dispatch: push: branches: - astria # Running this job only for astria branch - jobs: build-and-publish-latest: runs-on: ubuntu-latest From a8e87743e7bea5374c088c57ce3e5b92024545a6 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 28 Mar 2023 17:13:58 -0600 Subject: [PATCH 4/4] fix syntax --- .github/workflows/astria-build-and-publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/astria-build-and-publish-image.yml b/.github/workflows/astria-build-and-publish-image.yml index 58bfe6b82fe6..8544520ca30d 100644 --- a/.github/workflows/astria-build-and-publish-image.yml +++ b/.github/workflows/astria-build-and-publish-image.yml @@ -15,7 +15,7 @@ jobs: - run: go version - name: Log in to registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + 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