Skip to content

Commit

Permalink
dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
wo-o committed Oct 26, 2024
1 parent 7b90a36 commit 5423ab4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,56 @@ name: Build and Push to Docker Hub
on:
workflow_dispatch:
push:
branches:
- main
tags:
- '*'

env:
DOCKERHUB_REPOSITORY: jinnuae40/story-geth
NETWORK: iliad

jobs:
# Build and upload the geth binary
build_and_push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5

- name: Set build arguments
run: |
echo "REPOSITORY_URI=$DOCKERHUB_REPOSITORY" >> $GITHUB_ENV
- run: |
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VERSION=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "BUILDNUM=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "REPOSITORY_URI=$DOCKERHUB_REPOSITORY" >> $GITHUB_ENV
echo "NETWORK=$NETWORK" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- uses: actions/cache@v3
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/login-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- run: |
- name: Dockerize the geth and bootnode binary
env:
DOCKER_BUILDKIT: 1
run: |
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm64/v8 \
--build-arg BUILDNUM=$BUILDNUM \
--build-arg COMMIT=$COMMIT \
--build-arg VERSION=$VERSION \
--build-arg BUILDNUM=$BUILDNUM \
--build-arg NETWORK=$NETWORK \
-t $REPOSITORY_URI:latest \
-t $REPOSITORY_URI:$COMMIT \
-t $REPOSITORY_URI:$VERSION \
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ FROM golang:1.22-alpine as builder
RUN apk add --no-cache gcc musl-dev linux-headers git

# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download
COPY go.mod /story-geth/
COPY go.sum /story-geth/
RUN cd /story-geth && go mod download

ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
ADD . /story-geth
RUN cd /story-geth && go run build/ci.go install -static ./cmd/geth

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest

RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
COPY --from=builder /story-geth/build/bin/geth /usr/local/bin/

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

0 comments on commit 5423ab4

Please sign in to comment.