Skip to content

Commit

Permalink
Merge pull request #7 from hemilabs/clayton/op-node-docker
Browse files Browse the repository at this point in the history
Clayton/op node docker
  • Loading branch information
ClaytonNorthey92 authored Jul 12, 2024
2 parents d3f734b + 01ae485 commit 3085fb4
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 32 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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:
branches:
- main

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 }}
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.14.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.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=
Expand Down
60 changes: 35 additions & 25 deletions op-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
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 /optimism

WORKDIR /app

# 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 . .

RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH

FROM alpine:3.18

COPY --from=builder /usr/local/bin/op-node /usr/local/bin/op-node

CMD ["op-node"]
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/tree/hemi/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/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" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"

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"]
2 changes: 0 additions & 2 deletions op-node/Dockerfile.dockerignore

This file was deleted.

0 comments on commit 3085fb4

Please sign in to comment.