Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: execution client cloud image #1

Open
wants to merge 6 commits into
base: scalind-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile.scalind.cloud
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Support setting various labels on the final image
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.21-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

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

# Pull Geth into a second stage deploy alpine container
FROM docker.io/library/alpine:3.18

RUN apk add --no-cache ca-certificates aws-cli
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
COPY --from=builder /go-ethereum/scalind/entrypoint.sh /entrypoint.sh

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["/entrypoint.sh"]

# Add some metadata labels to help programatic image consumption
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ GOBIN = ./build/bin
GO ?= latest
GORUN = go run

DOCKER_REGISTRY ?= dock.getra.team
DOCKER_REPOSITORY ?= scalind/op-geth
IMAGE_TAG ?= latest

GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
BUILDNUM ?= 1
VERSION ?= 0.0.1

DOCKER_PLATFORMS ?= linux/amd64,linux/arm64
OUTPUT ?= docker

geth:
$(GORUN) build/ci.go install ./cmd/geth
@echo "Done building."
Expand Down Expand Up @@ -42,3 +53,13 @@ forkdiff:
--mount src=$(shell pwd),target=/host-pwd,type=bind \
protolambda/forkdiff:latest \
-repo /host-pwd/ -fork /host-pwd/fork.yaml -out /host-pwd/forkdiff.html

docker-cloud:
docker buildx build \
-t $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY):$(IMAGE_TAG) \
--platform=$(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(GIT_COMMIT) \
--build-arg BUILDNUM=$(BUILDNUM) \
--output=type=$(OUTPUT) \
-f Dockerfile.scalind.cloud .
57 changes: 57 additions & 0 deletions scalind/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

get_file_from_s3() {
if [[ -z $1 || -z $2 ]]; then
exit 1
fi
export AWS_ENDPOINT_URL=http://${SCALIND_S3_URL}
export AWS_ACCESS_KEY_ID=${SCALIND_S3_ACCESS_KEY}
export AWS_SECRET_ACCESS_KEY=${SCALIND_S3_SECRET_KEY}
aws s3 cp s3://${SCALIND_S3_BUCKET}/$1 $2 || exit 1
}

get_genesis_from_s3() {
get_file_from_s3 $SCALIND_S3_GENESIS_FILE_PATH ~/configs/genesis.json
echo "Genesis file downloaded from S3"
}

get_rollup_from_s3() {
get_file_from_s3 $SCALIND_S3_ROLLUP_FILE_PATH ~/configs/rollup.json
echo "Rollup file downloaded from S3"
}

DATADIR=/volume/datadir
ARGS="--datadir=$DATADIR"

if [[ -n $SCALIND_S3_URL && -n $SCALIND_S3_ACCESS_KEY && -n $SCALIND_S3_SECRET_KEY && -n $SCALIND_S3_BUCKET && -n $SCALIND_S3_GENESIS_FILE_PATH ]]; then
get_genesis_from_s3
fi

if [[ -f ~/configs/genesis.json ]]; then
if [[ ! -d /volume/datadir/geth ]]; then
echo "INFO: Data not found. Initializing from genesis file"
geth init $ARGS ~/configs/genesis.json || exit 1
echo "INFO: Chain datadir initialized"
fi
else
echo "ERROR: Genesis.json should be mounted or S3 connection options should be provided"
exit 1
fi

if [[ -f /secrets/jwt.txt ]]; then
ARGS="--authrpc.jwtsecret=/secrets/jwt.txt $ARGS"
else
echo "ERROR: File \"/secrets/jwt.txt\" should be present"
exit 1
fi

if [[ -n $SCALIND_CHAIN_ID ]]; then
ARGS="--networkid=$SCALIND_CHAIN_ID $ARGS"
else
echo "ERROR: Variable \"SCALIND_CHAIN_ID\" should be present"
exit 1
fi

ARGS="--http --http.corsdomain=* --http.vhosts=* --http.addr=0.0.0.0 --http.api=web3,debug,eth,txpool,net,engine --ws --ws.api=debug,eth,txpool,net,engine --nodiscover --maxpeers=0 --authrpc.vhosts="*" --authrpc.addr=0.0.0.0 --authrpc.port=8551 --authrpc.jwtsecret=./jwt.txt --rollup.disabletxpoolgossip=true --syncmode=full --gcmode=archive --ws.addr=0.0.0.0 --ws.port=8546 --ws.origins=* --authrpc.vhosts=* --authrpc.addr=0.0.0.0 --authrpc.port=8551 $ARGS"

geth $ARGS