-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
66 lines (52 loc) · 2.59 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# syntax=docker/dockerfile:1
# Simple usage with a mounted data directory:
# > make docker-build
# > docker run -it -p 26656:26656 -p 26657:26657 -v ~/.finschia:/root/.finschia -v finschia/finschianode fnsad init
# > docker run -it -p 26656:26656 -p 26657:26657 -v ~/.finschia:/root/.finschia -v finschia/finschianode fnsad start --rpc.laddr=tcp://0.0.0.0:26657 --p2p.laddr=tcp://0.0.0.0:26656
ARG GO_VERSION="1.22"
ARG RUNNER_IMAGE="alpine:3.18"
FROM golang:${GO_VERSION}-alpine3.18 AS build-env
ARG FINSCHIA_BUILD_OPTIONS=""
ARG GIT_VERSION
ARG GIT_COMMIT
ARG OST_VERSION
# Set up OS dependencies
RUN apk add --no-cache ca-certificates build-base linux-headers curl
# Set WORKDIR to finschia
WORKDIR /finschia-build/finschia
# Install GO dependencies
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
# Install libwasmvm.*.a
RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/Finschia/wasmvm | awk '{print $2}') && \
curl -L -f -o /lib/libwasmvm_muslc.a https://github.com/Finschia/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a && ls -al /lib/libwasmvm_muslc.a && \
# verify checksum
curl -L -f -o /tmp/checksums.txt https://github.com/Finschia/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt && ls -al /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1)
# Add source files
COPY . .
# Build fnsad binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
GOWORK=off go build \
-mod=readonly \
-tags "netgo,ledger,muslc,goleveldb" \
-ldflags \
"-X github.com/Finschia/finschia-sdk/version.Name=finschia \
-X github.com/Finschia/finschia-sdk/version.AppName=fnsad \
-X github.com/Finschia/finschia-sdk/version.Version=${GIT_VERSION} \
-X github.com/Finschia/finschia-sdk/version.Commit=${GIT_COMMIT} \
-X github.com/Finschia/ostracon/version.TMCoreSemVer=${OST_VERSION} \
-X github.com/Finschia/finschia-sdk/types.DBBackend=goleveldb \
-X github.com/Finschia/finschia-sdk/version.BuildTags=netgo,ledger,muslc,goleveldb \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /finschia-build/finschia/build/fnsad \
/finschia-build/finschia/cmd/fnsad
# Final image
FROM ${RUNNER_IMAGE}
WORKDIR /root
# Copy over binaries from the build-env
COPY --from=build-env /finschia-build/finschia/build/fnsad /usr/bin/fnsad