Skip to content
Draft
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
10 changes: 9 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ BeaconKit is a modular consensus client implementation that uses a modified Come
make build # Build beacond binary to build/bin/beacond
make build-docker # Build Docker image
make install # Install beacond to $GOPATH/bin
make clean-docker # Clean up Docker BuildX builder and cache
```

**Docker BuildX Requirements:**
- The `build-docker` target uses Docker BuildX for persistent caching and improved build performance
- BuildX is included in Docker Desktop and Docker Engine 19.03+
- The build process automatically creates a persistent builder instance named `beaconkit-builder`
- This builder maintains cached Go modules and build artifacts across builds
- To remove the builder and clear cache, run `make clean-docker`

### Running
```bash
make start # Start ephemeral devnet node (chain ID: 80087)
Expand Down Expand Up @@ -723,7 +731,7 @@ func ProvideBlockchainService(

### Dependencies
- Go 1.25.3+
- Docker (for running EL clients)
- Docker 19.03+ with BuildX (for Docker builds and running EL clients)
- Foundry (for Solidity contracts)
- Make (GNU Make)

Expand Down
35 changes: 11 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,7 @@ ARG DB_BACKEND=pebbledb
ARG CMD_PATH=./cmd/beacond

#######################################################
### Stage 1 - Cache Go Modules ###
#######################################################

FROM golang:${GO_VERSION}-alpine AS mod-cache

WORKDIR /workdir

RUN apk add --no-cache git

# Download Go modules
COPY ./go.mod ./go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

#######################################################
### Stage 2 - Build the Application ###
### Stage 1 - Build the Application ###
#######################################################

FROM golang:${GO_VERSION}-alpine AS builder
Expand All @@ -55,13 +39,16 @@ ARG BUILD_TAGS
# Set the working directory
WORKDIR /workdir

# Consolidate RUN commands to reduce layers
# Install dependencies
RUN apk add --no-cache --update \
ca-certificates \
build-base

# Copy the dependencies from the cache stage
COPY --from=mod-cache /go/pkg /go/pkg
COPY go.mod go.sum ./

# Download dependencies with cache mount - this will use buildx cache
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

# Copy all the source code (this will ignore files/dirs in .dockerignore)
COPY ./ ./
Expand All @@ -72,9 +59,9 @@ ARG APP_NAME
ARG DB_BACKEND
ARG CMD_PATH

# Build beacond
# Build beacond with cache mounts
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/go/pkg/mod \
env NAME=${NAME} DB_BACKEND=${DB_BACKEND} APP_NAME=${APP_NAME} CGO_ENABLED=1 && \
go build \
-mod=readonly \
Expand All @@ -91,7 +78,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
${CMD_PATH}

#######################################################
### Stage 3 - Prepare the Final Image ###
### Stage 2 - Prepare the Final Image ###
#######################################################

FROM ${RUNNER_IMAGE}
Expand All @@ -110,4 +97,4 @@ RUN mkdir -p /root/jwt /root/kzg && \
EXPOSE 26656
EXPOSE 26657

ENTRYPOINT [ "beacond" ]
ENTRYPOINT [ "beacond" ]
17 changes: 15 additions & 2 deletions scripts/build/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,17 @@ IMAGE_NAME ?= $(TESTAPP)
# Docker Paths
DOCKERFILE = ./Dockerfile

build-docker: ## build a docker image containing `beacond`
# Create buildx builder if it doesn't exist
.PHONY: docker-builder-setup
docker-builder-setup:
@docker buildx inspect beaconkit-builder 2>/dev/null || \
docker buildx create --name beaconkit-builder --driver docker-container
@docker buildx use beaconkit-builder

build-docker: docker-builder-setup ## build a docker image containing `beacond`
@echo "Build a release docker image for the Cosmos SDK chain..."
docker build \
docker buildx build \
--load \
--platform linux/$(ARCH) \
--build-arg GIT_COMMIT=$(shell git rev-parse HEAD) \
--build-arg GIT_VERSION=$(VERSION) \
Expand All @@ -117,3 +125,8 @@ push-docker-github: ## push the docker image to the ghcr registry
@echo "Push the release docker image to the ghcr registry..."
docker tag $(IMAGE_NAME):$(VERSION) ghcr.io/berachain/beacon-kit:$(VERSION)
docker push ghcr.io/berachain/beacon-kit:$(VERSION)

clean-docker: ## clean up docker builder and cache
@echo "Removing beaconkit-builder and clearing cache..."
@docker buildx rm beaconkit-builder || true
@echo "Docker builder cleanup complete"
Loading