From 154c44386ffeb93143631ce060eef2ffd1723ab9 Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Mon, 8 Jul 2024 10:56:53 -0400 Subject: [PATCH 1/4] simplified op-node docker image + github action to publish simplified op-node docker image to make op-node added github actions workflow to publish docker image --- .github/workflows/docker.yml | 66 +++++++++++++++++++++++++++++++++ go.mod | 2 +- op-node/Dockerfile | 34 ++++++----------- op-node/Dockerfile.dockerignore | 2 - 4 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/docker.yml delete mode 100644 op-node/Dockerfile.dockerignore diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000000..1adae4e7f495 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,66 @@ +# Copyright (c) 2024 Hemi Labs, Inc. +# Use of this source code is governed by the MIT License, +# which can be found in the LICENSE file. + +# GitHub Actions workflow to publish Docker images. +name: "Docker" +on: + push: + +concurrency: + group: "docker-${{ github.workflow }}-${{ github.event.number || github.ref }}" + cancel-in-progress: true + +jobs: + # Build and publish Docker image + docker: + name: "Docker" + if: ${{ github.repository_owner == 'hemilabs' }} + runs-on: "ubuntu-latest" + permissions: + contents: read + packages: write + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Setup QEMU" + uses: docker/setup-qemu-action@v3 + + - name: "Setup Docker Buildx" + uses: docker/setup-buildx-action@v3 + + - name: "Login to DockerHub" + uses: docker/login-action@v3 + with: + username: "${{ secrets.DOCKERHUB_USERNAME }}" + password: "${{ secrets.DOCKERHUB_TOKEN }}" + + - name: "Login to GitHub Container Registry" + uses: docker/login-action@v3 + with: + registry: "ghcr.io" + username: "${{ github.repository_owner }}" + password: "${{ secrets.GITHUB_TOKEN }}" + + - name: "Prepare" + id: "prepare" + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" + + - name: "Build and push" + uses: docker/build-push-action@v5 + with: + context: "${{ github.workspace }}" + platforms: "amd64" + file: "${{ github.workspace }}/op-node/Dockerfile" + push: true + build-args: | + VERSION=${{ steps.prepare.outputs.sha_short }} + VCS_REF=${{ github.sha }} + BUILD_DATE=${{ steps.prepare.outputs.build_date }} + tags: | + hemilabs/op-node:${{ steps.prepare.outputs.sha_short }} + ghcr.io/hemilabs/op-node:${{ steps.prepare.outputs.sha_short }} + diff --git a/go.mod b/go.mod index 9b8b8abb1945..b07cf7c1fe42 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.5 github.com/hashicorp/raft v1.6.1 github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e - github.com/hemilabs/heminetwork v0.1.3-0.20240626140326-27a5081e365a + github.com/hemilabs/heminetwork v0.2.0 github.com/holiman/uint256 v1.2.4 github.com/ipfs/go-datastore v0.6.0 github.com/ipfs/go-ds-leveldb v0.5.0 diff --git a/op-node/Dockerfile b/op-node/Dockerfile index f0efa74c7997..ff6f2f22ce69 100644 --- a/op-node/Dockerfile +++ b/op-node/Dockerfile @@ -1,32 +1,22 @@ -FROM --platform=$BUILDPLATFORM golang:1.21.1-alpine3.18 as builder +FROM golang:1.22.5-alpine3.20@sha256:8c9183f715b0b4eca05b8b3dbf59766aaedb41ec07477b132ee2891ac0110a07 AS builder -ARG VERSION=v0.0.0 +ARG VERSION=v0.0.0 TARGETOS TARGETARCH -RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash +RUN apk add git make -COPY ./go.mod /app/go.mod -COPY ./go.sum /app/go.sum +WORKDIR / +RUN git clone https://github.com/hemilabs/op-geth +WORKDIR /op-geth +RUN git checkout 83dd8a6e0459dd0f96182bb16065411f9318ac00 -WORKDIR /app +WORKDIR /optimism -# build op-node with the shared go.mod & go.sum files -COPY ./heminetwork /app/heminetwork -COPY ./op-node /app/op-node -COPY ./op-chain-ops /app/op-chain-ops -COPY ./op-service /app/op-service -COPY ./op-bindings /app/op-bindings -COPY ./.git /app/.git - -RUN go mod download - -WORKDIR /app/op-node - -ARG TARGETOS TARGETARCH +COPY . /optimism RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH -FROM alpine:3.18 +FROM alpine:3.20@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0 -COPY --from=builder /usr/local/bin/op-node /usr/local/bin/op-node +COPY --from=builder /optimism/op-node/bin/op-node /bin/op-node -CMD ["op-node"] +CMD ['op-node'] \ No newline at end of file diff --git a/op-node/Dockerfile.dockerignore b/op-node/Dockerfile.dockerignore deleted file mode 100644 index 4f26140750a0..000000000000 --- a/op-node/Dockerfile.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore everything but the dockerfile, the op-stack-go base image performs the build -* From 3f07ac756c7c78f14ca00e93ed63fecd64c64192 Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Tue, 9 Jul 2024 09:10:17 -0400 Subject: [PATCH 2/4] updated replace in go.mod --- go.mod | 5 +---- go.sum | 2 ++ op-node/Dockerfile | 5 ----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b07cf7c1fe42..06cae661999d 100644 --- a/go.mod +++ b/go.mod @@ -268,7 +268,4 @@ exclude ( ) -//replace github.com/ethereum/go-ethereum v1.13.5 => github.com/ethereum-optimism/op-geth v1.101304.2-0.20231130012434-cd5316814d08 - -//replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain -replace github.com/ethereum/go-ethereum v1.13.5 => ../op-geth +replace github.com/ethereum/go-ethereum v1.13.5 => github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459 diff --git a/go.sum b/go.sum index 03d62f79a3bf..a40f5539747c 100644 --- a/go.sum +++ b/go.sum @@ -386,6 +386,8 @@ github.com/hashicorp/raft v1.6.1 h1:v/jm5fcYHvVkL0akByAp+IDdDSzCNCGhdO6VdB56HIM= github.com/hashicorp/raft v1.6.1/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0= github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e h1:SK4y8oR4ZMHPvwVHryKI88kJPJda4UyWYvG5A6iEQxc= github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e/go.mod h1:EMz/UIuG93P0MBeHh6CbXQAEe8ckVJLZjhD17lBzK5Q= +github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459 h1:JQIMyVGTLA+VDV1KgZIWore5Fv6eJF9VHAUvTencIJA= +github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459/go.mod h1:C3O7ZM3VseOr8qIzLJrrlkfU7tG88Xn/cz60bAdoIWM= github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw= github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= diff --git a/op-node/Dockerfile b/op-node/Dockerfile index ff6f2f22ce69..23f8e43fb7f3 100644 --- a/op-node/Dockerfile +++ b/op-node/Dockerfile @@ -4,11 +4,6 @@ ARG VERSION=v0.0.0 TARGETOS TARGETARCH RUN apk add git make -WORKDIR / -RUN git clone https://github.com/hemilabs/op-geth -WORKDIR /op-geth -RUN git checkout 83dd8a6e0459dd0f96182bb16065411f9318ac00 - WORKDIR /optimism COPY . /optimism From aa11fb493193b150004fd5b6b50995456d9e691f Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Wed, 10 Jul 2024 14:30:35 -0400 Subject: [PATCH 3/4] pr feedback --- .github/workflows/docker.yml | 4 +++- go.mod | 2 +- go.sum | 4 ++-- op-node/Dockerfile | 25 +++++++++++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1adae4e7f495..412b21b22c0d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,8 @@ name: "Docker" on: push: + branches: + - main concurrency: group: "docker-${{ github.workflow }}-${{ github.event.number || github.ref }}" @@ -15,7 +17,7 @@ jobs: # Build and publish Docker image docker: name: "Docker" - if: ${{ github.repository_owner == 'hemilabs' }} + if: github.repository_owner == 'hemilabs' runs-on: "ubuntu-latest" permissions: contents: read diff --git a/go.mod b/go.mod index 06cae661999d..accdc94b41a2 100644 --- a/go.mod +++ b/go.mod @@ -268,4 +268,4 @@ exclude ( ) -replace github.com/ethereum/go-ethereum v1.13.5 => github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459 +replace github.com/ethereum/go-ethereum v1.13.5 => github.com/hemilabs/op-geth v1.14.1 diff --git a/go.sum b/go.sum index a40f5539747c..6e38a8bce8ea 100644 --- a/go.sum +++ b/go.sum @@ -386,8 +386,8 @@ github.com/hashicorp/raft v1.6.1 h1:v/jm5fcYHvVkL0akByAp+IDdDSzCNCGhdO6VdB56HIM= github.com/hashicorp/raft v1.6.1/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0= github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e h1:SK4y8oR4ZMHPvwVHryKI88kJPJda4UyWYvG5A6iEQxc= github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e/go.mod h1:EMz/UIuG93P0MBeHh6CbXQAEe8ckVJLZjhD17lBzK5Q= -github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459 h1:JQIMyVGTLA+VDV1KgZIWore5Fv6eJF9VHAUvTencIJA= -github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240705124236-83dd8a6e0459/go.mod h1:C3O7ZM3VseOr8qIzLJrrlkfU7tG88Xn/cz60bAdoIWM= +github.com/hemilabs/op-geth v1.14.1 h1:wWG7twTtFHcZlnnni3jq+LCoOPFaB9suwRIJnC2zADc= +github.com/hemilabs/op-geth v1.14.1/go.mod h1:C3O7ZM3VseOr8qIzLJrrlkfU7tG88Xn/cz60bAdoIWM= github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw= github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= diff --git a/op-node/Dockerfile b/op-node/Dockerfile index 23f8e43fb7f3..543f35fd1397 100644 --- a/op-node/Dockerfile +++ b/op-node/Dockerfile @@ -6,12 +6,33 @@ RUN apk add git make WORKDIR /optimism -COPY . /optimism +COPY . . RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH FROM alpine:3.20@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0 +ARG VERSION +ARG VCS_REF +ARG BUILD_DATE +LABEL org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.authors="Hemi Labs" \ + org.opencontainers.image.url="https://github.com/hemilabs/optimism/op-node" \ + org.opencontainers.image.source="https://github.com/hemilabs/optimism" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$VCS_REF \ + org.opencontainers.image.vendor="Hemi Labs" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.title="Optimism Op-Node" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name="Optimism Op-Node" \ + org.label-schema.url="https://github.com/hemilabs/optimism/op-node" \ + org.label-schema.vcs-url="https://github.com/hemilabs/optimism" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vendor="Hemi Labs" \ + org.label-schema.version=$VERSION \ + org.label-schema.schema-version="1.0" + COPY --from=builder /optimism/op-node/bin/op-node /bin/op-node -CMD ['op-node'] \ No newline at end of file +CMD ["op-node"] \ No newline at end of file From 01ae485cdd3652da83d0c9ece2b40da40b7c970c Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Wed, 10 Jul 2024 15:59:58 -0400 Subject: [PATCH 4/4] add user op-node, fix url --- op-node/Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/op-node/Dockerfile b/op-node/Dockerfile index 543f35fd1397..cd66e634b425 100644 --- a/op-node/Dockerfile +++ b/op-node/Dockerfile @@ -17,7 +17,7 @@ ARG VCS_REF ARG BUILD_DATE LABEL org.opencontainers.image.created=$BUILD_DATE \ org.opencontainers.image.authors="Hemi Labs" \ - org.opencontainers.image.url="https://github.com/hemilabs/optimism/op-node" \ + org.opencontainers.image.url="https://github.com/hemilabs/optimism/tree/hemi/op-node" \ org.opencontainers.image.source="https://github.com/hemilabs/optimism" \ org.opencontainers.image.version=$VERSION \ org.opencontainers.image.revision=$VCS_REF \ @@ -26,7 +26,7 @@ LABEL org.opencontainers.image.created=$BUILD_DATE \ org.opencontainers.image.title="Optimism Op-Node" \ org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="Optimism Op-Node" \ - org.label-schema.url="https://github.com/hemilabs/optimism/op-node" \ + org.label-schema.url="https://github.com/hemilabs/optimism/tree/hemi/op-node" \ org.label-schema.vcs-url="https://github.com/hemilabs/optimism" \ org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vendor="Hemi Labs" \ @@ -35,4 +35,8 @@ LABEL org.opencontainers.image.created=$BUILD_DATE \ COPY --from=builder /optimism/op-node/bin/op-node /bin/op-node +RUN adduser -D -s /bin/sh op-node + +USER op-node + CMD ["op-node"] \ No newline at end of file