mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
One toolchain across the estate. The tree carried 1.26.0, .1, .3, .4 and .5 at once, so which compiler built a binary depended on which repo it came from. Co-authored-by: Hanzo Dev <[email protected]>
70 lines
2.1 KiB
Docker
70 lines
2.1 KiB
Docker
# Custom build with local EVM plugin
|
|
# Must be a full patch version: the go-installer stage below fetches
|
|
# go${GO_VERSION}.linux-<arch>.tar.gz, and go.dev publishes no such tarball for
|
|
# a bare "1.26" (only 1.26.0, 1.26.1, ...), so a minor-only value 404s.
|
|
# Must also be >= the `go` directive in go.mod (1.26.8).
|
|
ARG GO_VERSION=1.26.8
|
|
|
|
# ============= Go Installation Stage ================
|
|
FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS go-installer
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
wget ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ARG GO_VERSION
|
|
ARG BUILDPLATFORM
|
|
|
|
RUN BUILDARCH=$(echo ${BUILDPLATFORM} | cut -d / -f2) && \
|
|
wget -q "https://go.dev/dl/go${GO_VERSION}.linux-${BUILDARCH}.tar.gz" && \
|
|
tar -C /usr/local -xzf "go${GO_VERSION}.linux-${BUILDARCH}.tar.gz" && \
|
|
rm "go${GO_VERSION}.linux-${BUILDARCH}.tar.gz"
|
|
|
|
# ============= Compilation Stage ================
|
|
FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS builder
|
|
|
|
COPY --from=go-installer /usr/local/go /usr/local/go
|
|
ENV PATH="/usr/local/go/bin:${PATH}"
|
|
|
|
# A go.mod `go` directive newer than the toolchain above is a hard failure
|
|
# under GOTOOLCHAIN=local. `auto` lets go fetch the required toolchain
|
|
# (checksum-verified via sum.golang.org) instead of dying at the floor.
|
|
ENV GOTOOLCHAIN=auto
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc libc6-dev make git ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod .
|
|
COPY go.sum .
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
|
|
RUN [ -d ./build ] && rm -rf ./build/* || true
|
|
|
|
ENV CGO_ENABLED=0
|
|
RUN export GOARCH=amd64 && ./scripts/build.sh
|
|
|
|
# Copy local EVM plugin instead of downloading
|
|
ARG EVM_VM_ID=mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6
|
|
RUN mkdir -p /luxd/build/plugins
|
|
COPY evm-plugin-linux-amd64 /luxd/build/plugins/${EVM_VM_ID}
|
|
RUN chmod +x /luxd/build/plugins/${EVM_VM_ID}
|
|
|
|
RUN mkdir -p /luxd/build
|
|
|
|
# ============= Runtime Stage ================
|
|
FROM debian:12-slim AS execution
|
|
|
|
COPY --from=builder /luxd/build /luxd/build
|
|
WORKDIR /luxd/build
|
|
|
|
COPY --from=builder /build/build/ .
|
|
|
|
RUN mkdir -p /luxd/build/plugins
|
|
|
|
CMD [ "./luxd" ]
|