When you think of a physicist often the image of an old man with white spiky hair pops into your mind whereas that of a young Muslim woman is probably the last thing you would think of. Defying the…
Build with Modules, Ship from Scratch
If you use dep, check out my previous post instead.
It is a multistage Dockerfile: the first throwaway stage is used for building, while the final image will only contain the compiled binary executable.
The dependencies are fetched at build time using the go.mod
and go.sum
files; an alternative Dockerfile for vendored dependencies is available at the bottom of this post.
Locking the dependencies using the go.sum
integrity checks will make sure that the code downloaded for a production build will match the dependencies you’ve set up locally… provided that they are still available on the remote origin.
Since I’m not paying per MB in my repository hosting, I often vendor dependencies to ensure both integrity and availability. Go 1.11 with enabled modules will only build using vendored dependencies when passed the flag -mod=vendor
.
If you are using a .dockerignore
exclusion file, remember to remove vendor/
from it and run go mod vendor
from your host machine, as this Dockerfile will expect all the dependencies already vendored.
It is a serious and honest question. It was one of the biggest decisions I made in my life. Was it the best decision I have ever made? No, but I do not regret it. Not even once. Life is too short for…
Lossless has created the world’s first unrivaled exploit identification and mitigation tools designed to foolproof Web3 from hacks. Through our shared mission toward user security, this partnership…
But I noticed that during the saddest and most troublesome times of my life, there was only one set of footprints. He whispered, “My precious child, I love you and will never leave you. Never, ever…