Skip to content

Commit 125ea8d

Browse files
committed
Build and Run Devnet
1 parent 3c208cd commit 125ea8d

File tree

3 files changed

+103
-7
lines changed

3 files changed

+103
-7
lines changed

.github/workflows/ci-build.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI Build and Push Docker Image
2+
3+
on:
4+
pull_request:
5+
types: [closed] # Trigger when the PR is closed (merged or just closed)
6+
branches:
7+
- master # Trigger only when code is pushed to the master branch
8+
9+
jobs:
10+
build:
11+
# Run the jobs only if the PR is merged and the label 'CI:Build' is present
12+
if: contains(github.event.pull_request.labels.*.name, 'CI:Build') && github.event.pull_request.merged == true
13+
runs-on: ubuntu:latest
14+
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
19+
- name: Get Version and Build number
20+
run: |
21+
VERSION="latest" # Simple static version; could be changed if needed
22+
BUILDNUM=${GITHUB_RUN_NUMBER} # Use the GitHub run number as the build number
23+
24+
# Set environment variables for later steps
25+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
26+
echo "BUILDNUM=${BUILDNUM}" >> $GITHUB_ENV
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Set up Docker Login
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKER_USERNAME }}
35+
password: ${{ secrets.DOCKER_PASSWORD }}
36+
37+
- name: Build Docker image
38+
run: |
39+
docker build -t ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} .
40+
41+
- name: Tag Docker image with 'latest'
42+
run: |
43+
docker tag ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest
44+
45+
- name: Push Docker image to Docker Hub
46+
run: |
47+
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }}
48+
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest
49+
50+
run-devnet:
51+
needs: build # Ensure this runs only after the build-and-push job
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: Checkout Code
56+
uses: actions/checkout@v4
57+
58+
- name: Set up Docker Compose
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y docker-compose
62+
63+
- name: Log in to Docker Hub
64+
uses: docker/login-action@v2
65+
with:
66+
username: ${{ secrets.DOCKER_USERNAME }}
67+
password: ${{ secrets.DOCKER_PASSWORD }}
68+
69+
- name: Run Devnet with Docker Compose
70+
run: |
71+
export DOCKER_HUB_USER=${{ secrets.DOCKER_USERNAME }}
72+
docker-compose up -d
73+
74+
- name: Verify Devnet
75+
run: |
76+
sleep 10 # Allow time for the devnet to start
77+
curl -X POST -H "Content-Type: application/json" \
78+
--data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' \
79+
http://localhost:8545
80+
81+
- name: Stop Devnet container
82+
run: |
83+
docker-compose down # Stops the containers and removes the network

Docker-Compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
devnet:
3+
image: $DOCKER_HUB_USER/go-ethereum:latest # Use the image built and pushed during build phase
4+
container_name: devnet
5+
ports:
6+
- "8545:8545" # Exposing RPC endpoint for interaction
7+
command: ["geth", "--dev", "--http", "--http.api", "web3,eth,net,personal", "--http.addr", "0.0.0.0", "--http.port", "8545"]
8+
networks:
9+
- devnet_network
10+
11+
networks:
12+
devnet_network:
13+
driver: bridge

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Support setting various labels on the final image
2-
ARG COMMIT=""
3-
ARG VERSION=""
4-
ARG BUILDNUM=""
2+
# ARG COMMIT=""
3+
# ARG VERSION=""
4+
# ARG BUILDNUM=""
55

66
# Build Geth in a stock Go builder container
77
FROM golang:1.23-alpine AS builder
@@ -26,8 +26,8 @@ EXPOSE 8545 8546 30303 30303/udp
2626
ENTRYPOINT ["geth"]
2727

2828
# Add some metadata labels to help programmatic image consumption
29-
ARG COMMIT=""
30-
ARG VERSION=""
31-
ARG BUILDNUM=""
29+
# ARG COMMIT=""
30+
# ARG VERSION=""
31+
# ARG BUILDNUM=""
3232

33-
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
33+
# LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"

0 commit comments

Comments
 (0)