Skip to content

Commit

Permalink
Add Docker autobuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
veaceslavdoina committed Jul 20, 2023
0 parents commit b788a2d
Show file tree
Hide file tree
Showing 1,063 changed files with 3,272 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Docker


on:
push:
branches:
- master
tags:
- 'v*.*.*'
paths-ignore:
- '**/*.md'
- docker-compose.yaml
workflow_dispatch:


env:
DOCKER_FILE: Dockerfile
DOCKER_REPO: codexstorage/dist-tests-geth


jobs:
# Build platform specific image
build:
strategy:
fail-fast: true
matrix:
target:
- os: linux
arch: amd64
- os: linux
arch: arm64
include:
- target:
os: linux
arch: amd64
builder: ubuntu-22.04
- target:
os: linux
arch: arm64
builder: buildjet-4vcpu-ubuntu-2204-arm

name: Build ${{ matrix.target.os }}/${{ matrix.target.arch }}
runs-on: ${{ matrix.builder }}
outputs:
tags-linux-amd64: ${{ steps.tags.outputs.tags-linux-amd64 }}
tags-linux-arm64: ${{ steps.tags.outputs.tags-linux-arm64 }}
env:
PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.target.arch) }}
SUFFIX: ${{ format('{0}-{1}', 'linux', matrix.target.arch) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker - Meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REPO }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}},suffix=-${{ env.SUFFIX }}
type=sha,suffix=-${{ env.SUFFIX }},enable=${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Docker - Set tags output
id: tags
run: |
if [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'amd64' ]]; then
echo "tags-linux-amd64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
elif [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'arm64' ]]; then
echo "tags-linux-arm64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
fi
- name: Docker - Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker - Build and Push
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.DOCKER_FILE }}
platforms: ${{ env.PLATFORM }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Publish single image
publish:
name: Push single image
runs-on: ubuntu-latest
needs: build
steps:
- name: Docker - Meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=semver,pattern={{version}}
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Docker - Set tags
run: |
# Transform multi-line tags in to the comma-seperated
TAGS=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ',' | awk '{gsub(/,$/,"");}1')
echo "TAGS=${TAGS}" >>$GITHUB_ENV
- name: Docker - Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker - Create and push manifest images
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.TAGS }}
images: ${{ needs.build.outputs.tags-linux-amd64 }},${{ needs.build.outputs.tags-linux-arm64 }}
push: true
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ethereum/client-go:v1.11.5

COPY content .

ENTRYPOINT ["/usr/bin/env"]
CMD ["sh", "docker-entrypoint.sh"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Geth for Codex Distributed Testing

We're wrapping the default image to get it to do what we want for our testing setup.
3 changes: 3 additions & 0 deletions content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We're copying the content folder into the geth image.
These files contain 1000 accounts and aprox. 300 already-mined blocks.
This is to prevent us having to wait until a sufficient number of accounts are created and blocks are mined before our tests can start.
1,002 changes: 1,002 additions & 0 deletions content/accounts.csv

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions content/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
UNLOCK_ACCOUNTS=""
if [ -n "$UNLOCK_START_INDEX" ]; then
INDEX=0
END_INDEX=$(($UNLOCK_START_INDEX + $UNLOCK_NUMBER))
while read p; do
if [ "$INDEX" -ge "$UNLOCK_START_INDEX" ]; then
if [ "$INDEX" -lt "$END_INDEX" ]; then
cat passwordsource >> passwordfile
UNLOCK_ACCOUNTS=$(echo $UNLOCK_ACCOUNTS$(echo $p | cut -d ',' -f 1), )
fi
fi
INDEX=$(($INDEX + 1))
done <accounts.csv

UNLOCK_ARGS="--unlock "$UNLOCK_ACCOUNTS" --password passwordfile"
fi

echo "Starting geth..."

if [ -n "$ENABLE_MINER" ]; then
MINER_ARGS="--mine --miner.etherbase 0x10420A3dE36231E12eb601F45b4004311372dcEa"
else
rm -Rf /root/.ethereum/geth
fi

echo "UNLOCK_ARGS: $UNLOCK_ARGS"
echo "MINER_ARGS: $MINER_ARGS"
echo "GETH_ARGS: $GETH_ARGS"

geth init genesis.json
geth --networkid 789988 --http --http.addr 0.0.0.0 --allow-insecure-unlock --http.vhosts '*' $UNLOCK_ARGS $MINER_ARGS $GETH_ARGS
exit 0
Loading

0 comments on commit b788a2d

Please sign in to comment.