Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
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
COPY result/bin/foo /usr/local/bin
./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
and won't start
bash: ./foo: No such file or directory
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 and justStaticExecutables, 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?
/nix/store/qb6k4hp7gk331x9fydw0w7qj4dv09bwz-glibc-2.27/lib/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f630f222000)
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.