Files
evm/Dockerfile
zeekayandHanzo Dev 3cc01984ee build: bump Go builder images to 1.26.5, set GOTOOLCHAIN=auto
Currency bump: golang builder images -> 1.26.5 (latest stable).

Adds ENV GOTOOLCHAIN=auto to each Go builder stage. The official golang
images set GOTOOLCHAIN=local, so a builder image older than the module's
go directive is a hard mid-build failure. The pin stays the hermetic fast
path; auto is the safety net for the next go.mod bump.

No go.mod go directive was changed. Builder images move; directives stay.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-01 16:25:47 -07:00

69 lines
2.6 KiB
Docker

# syntax=docker/dockerfile:1
# ============= Setting up base Stage ================
# LUXD_NODE_IMAGE needs to identify an existing node image and should include the tag
# This value is not intended to be used but silences a warning
ARG LUXD_NODE_IMAGE="invalid-image"
# ============= Compilation Stage ================
FROM --platform=$BUILDPLATFORM golang:1.26.5-bookworm AS builder
ENV GOTOOLCHAIN=auto
WORKDIR /build
# Copy lux dependencies first (intermediate docker image caching)
# Copy luxd directory if present (for manual CI case, which uses local dependency)
COPY go.mod go.sum luxd* ./
ENV GONOSUMCHECK=github.com/luxfi/*
ENV GONOSUMDB=github.com/lux-private/*
ENV GONOPROXY=github.com/lux-private/*
ENV GOFLAGS=-mod=mod
# Download lux dependencies using go mod
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download && go mod tidy
# Copy the code into the container
COPY . .
# Ensure pre-existing builds are not available for inclusion in the final image
RUN [ -d ./build ] && rm -rf ./build/* || true
ARG TARGETPLATFORM
ARG BUILDPLATFORM
# Configure a cross-compiler if the target platform differs from the build platform.
#
# build_env.sh is used to capture the environmental changes required by the build step since RUN
# environment state is not otherwise persistent.
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ] && [ "$BUILDPLATFORM" != "linux/arm64" ]; then \
apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
echo "export CC=aarch64-linux-gnu-gcc" > ./build_env.sh \
; elif [ "$TARGETPLATFORM" = "linux/amd64" ] && [ "$BUILDPLATFORM" != "linux/amd64" ]; then \
apt-get update && apt-get install -y gcc-x86-64-linux-gnu && \
echo "export CC=x86_64-linux-gnu-gcc" > ./build_env.sh \
; else \
echo "export CC=gcc" > ./build_env.sh \
; fi
# Pass in EVM_COMMIT as an arg to allow the build script to set this externally
ARG EVM_COMMIT
ARG CURRENT_BRANCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
. ./build_env.sh && \
echo "{CC=$CC, TARGETPLATFORM=$TARGETPLATFORM, BUILDPLATFORM=$BUILDPLATFORM}" && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) && \
export CURRENT_BRANCH=$CURRENT_BRANCH && \
export EVM_COMMIT=$EVM_COMMIT && \
./scripts/build.sh build/evm
# ============= Cleanup Stage ================
FROM $LUXD_NODE_IMAGE AS execution
# Copy the evm binary into the correct location in the container
ARG VM_ID=mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6
ENV LUXD_PLUGIN_DIR="/luxd/build/plugins"
COPY --from=builder /build/build/evm $LUXD_PLUGIN_DIR/$VM_ID