-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add static binary build in Dockerfile #1323
base: master
Are you sure you want to change the base?
Conversation
Thank you for the PR @mamirpanah. We'll take a look and review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Left a few comments to improve.
I'm curious, does this solution actually result in a working container that lets you run a full node?
FROM golang:1.22-alpine3.19 AS static-builder | ||
WORKDIR /app | ||
COPY . . | ||
RUN apk add --no-cache make git gcc linux-headers build-base curl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to an earlier layer to avoid rebuilding every time a file chances.
################################ | ||
FROM golang:1.22-alpine3.19 AS static-builder | ||
WORKDIR /app | ||
COPY . . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's usually better to copy only go.mod
and perform the download, then copy the remaining files and perform the build. That way, you don't touch dependencies for every build.
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ | ||
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a -O /lib/libwasmvm.$(uname -m).a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paloma uses a fixed version of libwasm
, which deviates from the latest. This needs to use the same version specified in the README
.
Also, move this step to the external dependency resolution layer above (apk add...
) to cache this properly.
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(go list -m github.com/cometbft/cometbft | sed 's:.* ::') \ | ||
-linkmode=external -extldflags '-Wl,-z,muldefs -static'" ./cmd/palomad | ||
|
||
ENTRYPOINT ["/app/build/palomad"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into two images, builder and runner. Runner image can be much slimmer by stripping all dependencies needed only for building. It also doesn't need a full copy of the source.
This PR aims to add static binary build in Dockerfile