Skip to content

Commit

Permalink
feat: copy genesis.json into Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
JossDuff committed Oct 25, 2024
1 parent adb4a21 commit 88d7e87
Show file tree
Hide file tree
Showing 5 changed files with 15,393 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push op-geth
name: Build and Deploy op-geth

on:
push:
Expand All @@ -7,9 +7,11 @@ on:

env:
REGISTRY: "registry.digitalocean.com/sigil"
DEPLOYMENT_NAME: op-geth
CONTAINER_NAME: op-geth

jobs:
build:
build-and-deploy:
runs-on: ubuntu-latest

steps:
Expand All @@ -22,7 +24,7 @@ jobs:
context: .
file: ./Dockerfile
push: false
tags: ${{ env.REGISTRY }}/op-geth:${{ github.sha }}
tags: ${{ env.REGISTRY }}/${{ env.CONTAINER_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -41,5 +43,16 @@ jobs:
file: ./Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/op-geth:${{ github.sha }}
${{ env.REGISTRY }}/op-geth:latest
${{ env.REGISTRY }}/${{ env.CONTAINER_NAME }}:${{ github.sha }}
${{ env.REGISTRY }}/${{ env.CONTAINER_NAME }}:latest
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.CLUSTER_NAME }}

- name: Update deployment image
run: |
kubectl set image statefulset/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${REGISTRY}/${CONTAINER_NAME}:${GITHUB_SHA}
- name: Verify deployment
run: |
kubectl rollout status statefulset/${DEPLOYMENT_NAME}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ profile.cov
# VS Code
.vscode

# so accidents don't happen
jwt.txt

# dashboard
/dashboard/assets/flow-typed
/dashboard/assets/node_modules
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Support setting various labels on the final image
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.23-alpine AS builder
Expand All @@ -13,6 +12,7 @@ COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

# copies all files (including genesis.json) to the builder stage
ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth

Expand All @@ -22,12 +22,14 @@ FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

# Copy genesis.json - this will fail if file doesn't exist
COPY --from=builder /go-ethereum/genesis.json /usr/local/bin/genesis.json

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]

# Add some metadata labels to help programmatic image consumption
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
LABEL commit="$COMMIT" version="$VERSION"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ Do not forget `--http.addr 0.0.0.0`, if you want to access RPC from other contai
and/or hosts. By default, `geth` binds to the local interface and RPC endpoints are not
accessible from the outside.

#### Docker image Building

Images are built automatically through the github action, but can be manually generated with

```bash
docker build \
--build-arg COMMIT=$(git rev-parse HEAD) \
--build-arg VERSION=$(git describe --tags --abbrev=0) \
-t op-geth:latest \
.
```

The `Dockerfile` requires a `genesis.json` in the project root. `genesis.json`
is generated in the rollup node, `op-node`. Read more about it in the
[op stack tutorial](https://docs.optimism.io/builders/chain-operators/tutorials/create-l2-rollup).

### Programmatically interfacing `geth` nodes

As a developer, sooner rather than later you'll want to start interacting with `geth` and the
Expand Down
Loading

0 comments on commit 88d7e87

Please sign in to comment.