mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
Build and Run Devnet
This commit is contained in:
parent
3c208cdea8
commit
125ea8de59
3 changed files with 103 additions and 7 deletions
83
.github/workflows/ci-build.yml
vendored
Normal file
83
.github/workflows/ci-build.yml
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
name: CI Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed] # Trigger when the PR is closed (merged or just closed)
|
||||||
|
branches:
|
||||||
|
- master # Trigger only when code is pushed to the master branch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# Run the jobs only if the PR is merged and the label 'CI:Build' is present
|
||||||
|
if: contains(github.event.pull_request.labels.*.name, 'CI:Build') && github.event.pull_request.merged == true
|
||||||
|
runs-on: ubuntu:latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get Version and Build number
|
||||||
|
run: |
|
||||||
|
VERSION="latest" # Simple static version; could be changed if needed
|
||||||
|
BUILDNUM=${GITHUB_RUN_NUMBER} # Use the GitHub run number as the build number
|
||||||
|
|
||||||
|
# Set environment variables for later steps
|
||||||
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||||
|
echo "BUILDNUM=${BUILDNUM}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Login
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} .
|
||||||
|
|
||||||
|
- name: Tag Docker image with 'latest'
|
||||||
|
run: |
|
||||||
|
docker tag ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }} ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest
|
||||||
|
|
||||||
|
- name: Push Docker image to Docker Hub
|
||||||
|
run: |
|
||||||
|
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:${{ env.BUILDNUM }}
|
||||||
|
docker push ${{ secrets.DOCKER_USERNAME }}/go-ethereum:latest
|
||||||
|
|
||||||
|
run-devnet:
|
||||||
|
needs: build # Ensure this runs only after the build-and-push job
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Compose
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y docker-compose
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Run Devnet with Docker Compose
|
||||||
|
run: |
|
||||||
|
export DOCKER_HUB_USER=${{ secrets.DOCKER_USERNAME }}
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
- name: Verify Devnet
|
||||||
|
run: |
|
||||||
|
sleep 10 # Allow time for the devnet to start
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
--data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' \
|
||||||
|
http://localhost:8545
|
||||||
|
|
||||||
|
- name: Stop Devnet container
|
||||||
|
run: |
|
||||||
|
docker-compose down # Stops the containers and removes the network
|
||||||
13
Docker-Compose.yml
Normal file
13
Docker-Compose.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
services:
|
||||||
|
devnet:
|
||||||
|
image: $DOCKER_HUB_USER/go-ethereum:latest # Use the image built and pushed during build phase
|
||||||
|
container_name: devnet
|
||||||
|
ports:
|
||||||
|
- "8545:8545" # Exposing RPC endpoint for interaction
|
||||||
|
command: ["geth", "--dev", "--http", "--http.api", "web3,eth,net,personal", "--http.addr", "0.0.0.0", "--http.port", "8545"]
|
||||||
|
networks:
|
||||||
|
- devnet_network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
devnet_network:
|
||||||
|
driver: bridge
|
||||||
14
Dockerfile
14
Dockerfile
|
|
@ -1,7 +1,7 @@
|
||||||
# Support setting various labels on the final image
|
# Support setting various labels on the final image
|
||||||
ARG COMMIT=""
|
# ARG COMMIT=""
|
||||||
ARG VERSION=""
|
# ARG VERSION=""
|
||||||
ARG BUILDNUM=""
|
# ARG BUILDNUM=""
|
||||||
|
|
||||||
# Build Geth in a stock Go builder container
|
# Build Geth in a stock Go builder container
|
||||||
FROM golang:1.23-alpine AS builder
|
FROM golang:1.23-alpine AS builder
|
||||||
|
|
@ -26,8 +26,8 @@ EXPOSE 8545 8546 30303 30303/udp
|
||||||
ENTRYPOINT ["geth"]
|
ENTRYPOINT ["geth"]
|
||||||
|
|
||||||
# Add some metadata labels to help programmatic image consumption
|
# Add some metadata labels to help programmatic image consumption
|
||||||
ARG COMMIT=""
|
# ARG COMMIT=""
|
||||||
ARG VERSION=""
|
# ARG VERSION=""
|
||||||
ARG BUILDNUM=""
|
# ARG BUILDNUM=""
|
||||||
|
|
||||||
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
# LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue