FROM golang:1.21-alpine AS build-env # Set up dependencies # bash, jq, curl for debugging # git, make for installation # libc-dev, gcc, linux-headers, eudev-dev are used for cgo and ledger installation RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl # Set working directory for the build WORKDIR /root/0g-chain # default home directory is /root # Copy dependency files first to facilitate dependency caching COPY ./go.mod ./ COPY ./go.sum ./ # Download dependencies RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ go version && go mod download # Cosmwasm - Download correct libwasmvm version RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ -O /lib/libwasmvm.$ARCH.a && \ # verify checksum wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ sha256sum /lib/libwasmvm.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) # Add source files COPY . . #ENV LEDGER_ENABLED False # Mount go build and mod caches as container caches, persisted between builder invocations RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ LINK_STATICALLY=true \ make install FROM alpine:3.15 RUN apk add bash jq curl COPY --from=build-env /go/bin/0gchaind /bin/0gchaind CMD ["0gchaind"]