forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hemilabs/clayton/op-node-docker
Clayton/op node docker
- Loading branch information
Showing
5 changed files
with
107 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file was deleted.
Oops, something went wrong.