I thought I'd try Nix with one of the systems at work. However, building with Nix, and then using the standard way of creating a Docker image, i.e. COPY result/bin/foo /usr/local/bin, results in the image containing a binary that looks a bit wonky
file ./foo
./foo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/qb6k4hp7gk331x9fydw0w7qj4dv09bwz-glibc-2.27/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
Nope, just changed the building of the binaries, stack -> nix.
Wanted to take one step at a time and not scare co-workers too much :grinning_face_with_smiling_eyes:
Thanks! I ended up going with the standard stuff though, haskellPackages.developPackage and dockerTools.buildImage, and it turns out it's rather a lot easier than I initially thought. Only a few small things I need to work out before I can ditch Dockerfile completely.
I just published this blog post, which is tangentially related to the topic (basically a similar problem but in the context of CI, and while avoiding rebuilds): https://www.srid.ca/nix-docker-ci-decouple
I thought I'd try Nix with one of the systems at work. However, building with Nix, and then using the standard way of creating a Docker image, i.e.
COPY result/bin/foo /usr/local/bin
, results in the image containing a binary that looks a bit wonkyand won't start
Is there some easy way out of this?
Are you using
pkgs.dockerTools
?Nope, just changed the building of the binaries,
stack
->nix
.Wanted to take one step at a time and not scare co-workers too much :grinning_face_with_smiling_eyes:
try statically linking your binaries
I tried adding both
enableStaticLibraries
andjustStaticExecutables
, but no luck there.I guess I'll have to have a look at
pkgs.dockerTools
sooner than I hoped for.Could it be that link to the linker that's to blame?
https://vaibhavsagar.com/blog/2019/08/11/ihaskell-nix-docker/
Thanks! I ended up going with the standard stuff though,
haskellPackages.developPackage
anddockerTools.buildImage
, and it turns out it's rather a lot easier than I initially thought. Only a few small things I need to work out before I can ditchDockerfile
completely.(deleted)
I just published this blog post, which is tangentially related to the topic (basically a similar problem but in the context of CI, and while avoiding rebuilds): https://www.srid.ca/nix-docker-ci-decouple