From 4b69dbe65d5292f631078210d3feb97cecddf59f Mon Sep 17 00:00:00 2001 From: jossduff Date: Wed, 23 Oct 2024 18:30:12 -0400 Subject: [PATCH 1/6] feat: action to build docker images on push to develop branch --- .github/workflows/build-docker-images.yml | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/build-docker-images.yml diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml new file mode 100644 index 000000000000..0c6e9020b68e --- /dev/null +++ b/.github/workflows/build-docker-images.yml @@ -0,0 +1,48 @@ +name: Build Docker Images + +on: + push: + branches: + - develop + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + component: [op-node, op-batcher, op-proposer] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/${{ matrix.component }} + tags: | + type=sha,prefix=${{ matrix.component }}- + type=ref,event=branch + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./${{ matrix.component }} + file: ./${{ matrix.component }}/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From e4e98e0b7a35b457328d59421bd6c7ec0e439a79 Mon Sep 17 00:00:00 2001 From: jossduff Date: Wed, 23 Oct 2024 18:34:18 -0400 Subject: [PATCH 2/6] removed github container registry upload --- .github/workflows/build-docker-images.yml | 24 +++-------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 0c6e9020b68e..3bc14d73133a 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -19,30 +19,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }}/${{ matrix.component }} - tags: | - type=sha,prefix=${{ matrix.component }}- - type=ref,event=branch - type=raw,value=latest - - - name: Build and push Docker image + - name: Build Docker image uses: docker/build-push-action@v5 with: context: ./${{ matrix.component }} file: ./${{ matrix.component }}/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + push: false + tags: ${{ matrix.component }}:latest cache-from: type=gha cache-to: type=gha,mode=max From 2f23b56a0e5cb97981a16da2b3187c951bcbb9e6 Mon Sep 17 00:00:00 2001 From: jossduff Date: Thu, 24 Oct 2024 14:28:27 -0400 Subject: [PATCH 3/6] feat: upload image to Digital Ocean --- .github/workflows/build-docker-images.yml | 30 -------------- .github/workflows/docker-images.yml | 48 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/build-docker-images.yml create mode 100644 .github/workflows/docker-images.yml diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml deleted file mode 100644 index 3bc14d73133a..000000000000 --- a/.github/workflows/build-docker-images.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build Docker Images - -on: - push: - branches: - - develop - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - component: [op-node, op-batcher, op-proposer] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build Docker image - uses: docker/build-push-action@v5 - with: - context: ./${{ matrix.component }} - file: ./${{ matrix.component }}/Dockerfile - push: false - tags: ${{ matrix.component }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml new file mode 100644 index 000000000000..cbce36e60add --- /dev/null +++ b/.github/workflows/docker-images.yml @@ -0,0 +1,48 @@ +name: Build and Push Docker Images + +on: + push: + branches: + - develop + +env: + REGISTRY: "registry.digitalocean.com/sigil" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + component: [op-node, op-batcher, op-proposer] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build container image + uses: docker/build-push-action@v5 + with: + context: ./${{ matrix.component }} + file: ./${{ matrix.component }}/Dockerfile + push: false + tags: ${{ env.REGISTRY }}/${{ matrix.component }}:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Log in to DO Container Registry + run: doctl registry login --expiry-seconds 1200 + + - name: Push image to DO Container Registry + uses: docker/build-push-action@v5 + with: + context: ./${{ matrix.component }} + file: ./${{ matrix.component }}/Dockerfile + push: true + tags: | + ${{ env.REGISTRY }}/${{ matrix.component }}:${{ github.sha }} + ${{ env.REGISTRY }}/${{ matrix.component }}:latest From 109c2cd7d6bfc62c5fd598c3fe3d910d39f54e53 Mon Sep 17 00:00:00 2001 From: jossduff Date: Fri, 25 Oct 2024 16:05:08 -0400 Subject: [PATCH 4/6] fix: build docker images according to the optimism build system --- .github/workflows/build-and-push-images.yml | 48 +++++++++++++++++++++ .github/workflows/docker-images.yml | 48 --------------------- 2 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/build-and-push-images.yml delete mode 100644 .github/workflows/docker-images.yml diff --git a/.github/workflows/build-and-push-images.yml b/.github/workflows/build-and-push-images.yml new file mode 100644 index 000000000000..5ef23024396b --- /dev/null +++ b/.github/workflows/build-and-push-images.yml @@ -0,0 +1,48 @@ +name: Build and Push Docker Images + +on: + push: + branches: [ "develop" ] + workflow_dispatch: # Allows manual triggering + +env: + REGISTRY: registry.digitalocean.com + REPOSITORY: sigil + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Authenticate with Digital Ocean registry + - name: Log in to DO Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + # Build and push each image + - name: Build and push images + uses: docker/bake-action@v4 + with: + files: ./docker-bake.hcl + targets: | + op-node + op-batcher + op-proposer + push: true + set: | + *.REGISTRY=${{ env.REGISTRY }} + *.REPOSITORY=${{ env.REPOSITORY }} + *.IMAGE_TAGS=${{ github.sha }},latest + *.PLATFORMS=linux/amd64 diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml deleted file mode 100644 index cbce36e60add..000000000000 --- a/.github/workflows/docker-images.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Push Docker Images - -on: - push: - branches: - - develop - -env: - REGISTRY: "registry.digitalocean.com/sigil" - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - component: [op-node, op-batcher, op-proposer] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Build container image - uses: docker/build-push-action@v5 - with: - context: ./${{ matrix.component }} - file: ./${{ matrix.component }}/Dockerfile - push: false - tags: ${{ env.REGISTRY }}/${{ matrix.component }}:${{ github.sha }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Install doctl - uses: digitalocean/action-doctl@v2 - with: - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - - name: Log in to DO Container Registry - run: doctl registry login --expiry-seconds 1200 - - - name: Push image to DO Container Registry - uses: docker/build-push-action@v5 - with: - context: ./${{ matrix.component }} - file: ./${{ matrix.component }}/Dockerfile - push: true - tags: | - ${{ env.REGISTRY }}/${{ matrix.component }}:${{ github.sha }} - ${{ env.REGISTRY }}/${{ matrix.component }}:latest From 942747401876a27d578e9d4e4905497b1d1651aa Mon Sep 17 00:00:00 2001 From: jossduff Date: Fri, 25 Oct 2024 16:11:46 -0400 Subject: [PATCH 5/6] fix: push new image to cluster --- .github/workflows/build-and-push-images.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/build-and-push-images.yml b/.github/workflows/build-and-push-images.yml index 5ef23024396b..615fab208e06 100644 --- a/.github/workflows/build-and-push-images.yml +++ b/.github/workflows/build-and-push-images.yml @@ -46,3 +46,14 @@ jobs: *.REPOSITORY=${{ env.REPOSITORY }} *.IMAGE_TAGS=${{ github.sha }},latest *.PLATFORMS=linux/amd64 + + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save ${{ secrets.CLUSTER_NAME }} + + - name: Update deployment image + run: | + kubectl set image statefulset/${{ matrix.deployment }} ${{ matrix.component }}=${REGISTRY}/${{ matrix.component }}:${GITHUB_SHA} + + - name: Verify deployment + run: | + kubectl rollout status statefulset/${{ matrix.deployment }} From 6ab36ac6fc3e7ac8879247112957095e2d0530ec Mon Sep 17 00:00:00 2001 From: jossduff Date: Fri, 25 Oct 2024 17:08:43 -0400 Subject: [PATCH 6/6] feat: include rollup.json in op-node image --- ops/README.md | 6 ++++++ ops/docker/op-stack-go/Dockerfile | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ops/README.md b/ops/README.md index b41f08d84911..b5fef31aa54d 100644 --- a/ops/README.md +++ b/ops/README.md @@ -1,3 +1,9 @@ # ops Various operational packages + +## Building op-node + +Building the image for `op-node` requires `rollup.json` to be in the project +root. You can read more about how to generate `rollup.json` in the [op-stack +tutorial](https://docs.optimism.io/builders/chain-operators/tutorials/create-l2-rollup#generate-the-l2-config-files). diff --git a/ops/docker/op-stack-go/Dockerfile b/ops/docker/op-stack-go/Dockerfile index 46105539c51a..a56ac67f4975 100644 --- a/ops/docker/op-stack-go/Dockerfile +++ b/ops/docker/op-stack-go/Dockerfile @@ -125,6 +125,8 @@ CMD ["op-wheel"] FROM --platform=$TARGETPLATFORM $TARGET_BASE_IMAGE AS op-node-target COPY --from=op-node-builder /app/op-node/bin/op-node /usr/local/bin/ +# also copy rollup.json into the image +COPY ./rollup.json /rollup.json CMD ["op-node"] FROM --platform=$TARGETPLATFORM $TARGET_BASE_IMAGE AS op-challenger-target