2024-03-23 01:27:21 +00:00
|
|
|
FROM golang:1.21-alpine AS build-env
|
2019-11-25 19:24:46 +00:00
|
|
|
|
|
|
|
# Set up dependencies
|
2020-09-01 15:35:37 +00:00
|
|
|
# bash, jq, curl for debugging
|
2019-11-25 19:24:46 +00:00
|
|
|
# git, make for installation
|
2020-09-01 15:35:37 +00:00
|
|
|
# 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
|
2019-11-25 19:24:46 +00:00
|
|
|
|
|
|
|
# Set working directory for the build
|
2024-05-01 04:25:00 +00:00
|
|
|
WORKDIR /root/0g-chain
|
2019-11-25 19:24:46 +00:00
|
|
|
# default home directory is /root
|
|
|
|
|
2023-11-08 22:06:03 +00:00
|
|
|
# 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
|
|
|
|
|
2024-07-17 09:47:09 +00:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
2019-11-25 19:24:46 +00:00
|
|
|
# Add source files
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
#ENV LEDGER_ENABLED False
|
2022-04-21 20:16:28 +00:00
|
|
|
|
|
|
|
# Mount go build and mod caches as container caches, persisted between builder invocations
|
2022-01-08 00:39:27 +00:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
2022-04-21 20:16:28 +00:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2024-07-17 09:47:09 +00:00
|
|
|
LINK_STATICALLY=true \
|
2022-01-08 00:39:27 +00:00
|
|
|
make install
|
|
|
|
|
|
|
|
FROM alpine:3.15
|
|
|
|
|
|
|
|
RUN apk add bash jq curl
|
2024-05-01 04:25:00 +00:00
|
|
|
COPY --from=build-env /go/bin/0gchaind /bin/0gchaind
|
2019-11-25 19:24:46 +00:00
|
|
|
|
2024-05-01 04:25:00 +00:00
|
|
|
CMD ["0gchaind"]
|