-
Notifications
You must be signed in to change notification settings - Fork 1
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
Build dateilager within the dockerfile using the nix environment #86
Conversation
10b9a4d
to
656a326
Compare
656a326
to
bc25ab3
Compare
bc25ab3
to
42a6646
Compare
go install github.com/bojand/ghz/cmd/[email protected] | ||
go install github.com/gadget-inc/fsdiff/cmd/[email protected] | ||
go install github.com/stamblerre/gocode@latest | ||
go install golang.org/x/tools/cmd/goimports@latest |
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.
Stuck these in the nix env, and then removed the ones that now come bundled with vscode (gocode => gopls, goimports is bundled also). This way, the versions used are the same in dev and in docker
@@ -20,8 +33,11 @@ RUN mkdir -p /home/main/secrets | |||
VOLUME /home/main/secrets/tls | |||
VOLUME /home/main/secrets/paseto | |||
|
|||
COPY release/server_linux_amd64 server | |||
COPY --from=build-stage /app/release/server_linux_${TARGETARCH} server |
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.
Did the nice multistage thing so all the build deps aren't in the final image
protoc-gen-go-grpc | ||
go-migrate | ||
mkcert | ||
]; |
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.
This makes the devShell build all the stuff you need to work on DL into your shell, but doesn't build DL itself. I always found that annoying with the original setup that I think Kira created that cd-ing into the dir built the whole project, which doesn't work so good when you are working on it and it might be busted.
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.
I'm down to properly Nix convert the project, it was in a very half converted state for a while.
But I do really miss the ability to control package versions, if ever Nix updates a package before we want to we're SOL.
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 possible in nix, it's just annoying! You add a new dep at the top of a file for a nixpkgs sha that has the version of the thing you actually want, and then you refer to that version of nixpkgs in your exported packages! We did it in gadget a couple times when we didn't want to upgrade things.
42a6646
to
da16b06
Compare
This switches the build process to: - build DL within the dockerfile for repeatable builds, instead of copying in from outside - use the nix environment to setup the env for the build, so it's the same go version / protoc version etc etc in and outside of docker - use a multistage docker build so we have slim containers with just the binary at the end I did all this because I was fighting to get a docker image built for linux_arm64, which is what orbstack needs to run the image locally in a k8s setup! It was annoying. This also adds linux_arm64 as a build target to the makefile, and teaches the dockerfile how to build the binary for the target architecture that the dockerfile is building for. Yeesh.
da16b06
to
f0fc487
Compare
This switches the build process to:
I did all this because I was fighting to get a docker image built for linux_arm64, which is what orbstack needs to run the image locally in a k8s setup! It was annoying. This also adds linux_arm64 as a build target to the makefile, and teaches the dockerfile how to build the binary for the target architecture that the dockerfile is building for.
Yeesh.