Skip to content

Commit 4860e01

Browse files
authored
Added mycelo Dockerfile and GH workflow for testing it (#2156)
* Added mycelo Dockerfile and GH workflow for testing it * Remove branch trigger * Using golang 1.18 * Rename workflow * Using a subfolder for genesis * Cancel image build for concurrent commits in same PR * Remove currency config * Go version 1.19. Setting commits in the image * Fix typo * Update folder reference
1 parent b9a80e5 commit 4860e01

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

Diff for: .github/workflows/mycelo-docker-image.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build mycelo image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
pull_request:
9+
branches:
10+
- master
11+
12+
concurrency:
13+
group: mycelo-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build-mycelo-image:
18+
name: Build mycelo image
19+
runs-on: [self-hosted, blockchain, 8-cpu]
20+
steps:
21+
- name: Checkout celo-blockchain repo
22+
uses: actions/checkout@v3
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v2
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v2
27+
- name: Build mycelo image
28+
uses: docker/build-push-action@v4
29+
with:
30+
context: .
31+
file: ./Dockerfile.mycelo
32+
push: false
33+
tags: mycelo:latest
34+
load: true
35+
build-args: GETH_COMMIT={{ github.sha }}
36+
- name: Check docker images
37+
run: docker images
38+
- name: Generate genesis.json using mycelo image
39+
run: |
40+
mkdir genesis
41+
docker run \
42+
--rm \
43+
--name mycelo \
44+
-v $(pwd)/genesis:/genesis \
45+
-w /genesis \
46+
mycelo:latest \
47+
"/usr/local/bin/mycelo genesis \
48+
--buildpath /contracts \
49+
--template loadtest \
50+
--validators 1 \
51+
--dev.accounts 1 \
52+
--blockperiod 5 \
53+
--epoch 600 \
54+
--blockgaslimit 30000000 \
55+
--mnemonic \"flock crumble custom public elder fix picnic title naive today update load delay jeans curtain engage radar flag trap maple help sustain chapter still\""
56+
- name: Print genesis.json
57+
run: |
58+
head -n 30 $(pwd)/genesis/genesis.json

Diff for: Dockerfile.mycelo

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Build Geth in a stock Go builder container
2+
FROM golang:1.19-alpine as builder
3+
4+
RUN apk add --no-cache make gcc musl-dev linux-headers git
5+
6+
ADD . /go-ethereum
7+
RUN cd /go-ethereum && make all-musl
8+
9+
FROM node:18-bullseye-slim as monorepo
10+
RUN apt-get update && apt install -y git
11+
ADD ./monorepo_commit /monorepo_commit
12+
RUN git clone https://github.com/celo-org/celo-monorepo /celo-monorepo && \
13+
cd /celo-monorepo && \
14+
git checkout $(cat /monorepo_commit)
15+
RUN apt-get update && \
16+
apt-get install -y lsb-release && \
17+
apt-get install -y curl build-essential python2 pkg-config libsecret-1-dev libudev-dev libusb-dev libusb-1.0-0 bash
18+
RUN cd /celo-monorepo && \
19+
yarn install --network-timeout 100000 --frozen-lockfile && \
20+
yarn cache clean && \
21+
yarn build
22+
23+
# Pull all binaries into a second stage deploy alpine container
24+
FROM alpine:latest
25+
ARG COMMIT_SHA
26+
27+
RUN apk add --no-cache ca-certificates
28+
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
29+
COPY --from=builder /go-ethereum/monorepo_commit /monorepo_commit
30+
COPY --from=monorepo /celo-monorepo/packages/protocol/build/contracts /contracts/contracts/
31+
COPY --from=monorepo /celo-monorepo/packages/protocol/build/contracts-mento /contracts/contracts-mento/
32+
RUN echo $COMMIT_SHA > /version.txt
33+
34+
# Using "/bin/sh -c" as the entrypoint to allow executing multiple commands directly from docker run
35+
ENTRYPOINT ["/bin/sh", "-c"]
36+
37+
# Add some metadata labels to help programatic image consumption
38+
ARG GETH_COMMIT=""
39+
40+
LABEL GETH_COMMIT="$COMMIT"

0 commit comments

Comments
 (0)