-
Notifications
You must be signed in to change notification settings - Fork 608
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
Fix reproducible linux builds #2427
Conversation
Looks like we will need to modify e2e tests for this change, will look into it |
Thanks @czarcas7ic |
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.
Seems like its good to go now, just had to specify start command in e2e now that we took it out form the Dockerfile (I think that was the right move FWIW)
COPY go.mod go.mod | ||
COPY go.sum go.sum |
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.
Consider doing this in one command to minimize the number of layers. As per:
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers
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! I'add in the next PR I'm making so we don't have to review again the changes
VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \ | ||
COMMIT=$(git log -1 --format='%H') && \ | ||
go build \ | ||
-mod=readonly \ | ||
-tags "netgo,ledger,muslc" \ | ||
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="osmosis" \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName="osmosisd" \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$VERSION \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$COMMIT \ | ||
-X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \ | ||
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ | ||
-trimpath \ | ||
-o /osmosis/build/ \ | ||
./... |
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.
Is there a make command we should be running, instead of copying this here?
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.
Not sure if there is already a make
target that will generate the go build
command with all these flags.
We could for sure write one but avoiding using the Makefile in the Dockerfile was intentional. It makes the image creation more transparent and immediate.
* Avoid hardcoding CosmWasm version * Improve Dockerfile and enable reproducible builds * add start cmd to e2e test Co-authored-by: Adam Tucker <adam@osmosis.team> (cherry picked from commit c83936c) # Conflicts: # Dockerfile # tests/e2e/containers/containers.go
* Fix reproducible linux builds (#2427) * Avoid hardcoding CosmWasm version * Improve Dockerfile and enable reproducible builds * add start cmd to e2e test Co-authored-by: Adam Tucker <adam@osmosis.team> (cherry picked from commit c83936c) # Conflicts: # Dockerfile # tests/e2e/containers/containers.go * Fix conflicts in Dockerfile * Remove unconsistent file * Replace command to get cosmwasm version * add fix Co-authored-by: Niccolo Raspa <6024049+niccoloraspa@users.noreply.github.com> Co-authored-by: Niccolo Raspa <nraspa@live.it> Co-authored-by: Adam Tucker <adam@osmosis.team>
Closes: #2362
What is the purpose of the change
This PR:
🐳 General Dockerfile improvements:
go
dependencieslibwasm
go build...
command🛠 Reproducible build idea:
cp
the binary out of the container and place it in the build folderThese simple changes drastically simplify the build process, and they allow very nice improvements:
osmobuilder
is now deprecated as the functionality is now integrated in the mainDockerfile
osmobuilder
allows to deprecated the wholecontrib/
folder, that can now be removed.We can now backport this build process to all
vX
branches to have consistent way to build theosmosisd
binary across all versions (only difference would be the CosmWasm line)The generalization of the runner image allows to create different flavour of the images starting from the same Dockerfile. This can be used to:
osmosis
Docker image (distroless
,nonroot
,alpine
)I will create issues for every point.
Brief Changelog
Dockerfile
Makefile
to create reproducible builds for linuxTesting and Verifying
You can build the binaries with:
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no