Closed prolic closed 2 years ago
I'm trying this out right now and I'm confused. What exactly is accomplished by the container? Installation of stack on the host is still required? I had hoped for a way to compile the app and get a user-space runnable binary that was compiled in the container.
following the instructions I also ran into the same issue I had before:
$ stack --docker-image=futr build
DRBG > using precompiled package
RSA > using precompiled package
bifunctors > using precompiled package
http-api-data > using precompiled package
http-client > using precompiled package
monad-control > using precompiled package
websockets > using precompiled package
x509 > using precompiled package
nanovg > configure
secp256k1-schnorr > using precompiled package
assoc > using precompiled package
profunctors > using precompiled package
semigroupoids > using precompiled package
text-show > using precompiled package
authenticate-oauth> using precompiled package
nanovg > Configuring nanovg-0.8.0.0...
nanovg > Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: The pkg-config package 'glew' is
nanovg > required but it could not be found.
nanovg >
Progress 15/38
-- While building package nanovg-0.8.0.0 (scroll up to its section to see the error) using:
/home/leo/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 configure --with-ghc=/home/leo/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/bin/ghc-8.10.7 --with-ghc-pkg=/home/leo/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/bin/ghc-pkg-8.10.7 --user --package-db=clear --package-db=global --package-db=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/pkgdb --libdir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/lib --bindir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/bin --datadir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/share --libexecdir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/libexec --sysconfdir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/etc --docdir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/doc/nanovg-0.8.0.0 --htmldir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/doc/nanovg-0.8.0.0 --haddockdir=/home/leo/.stack/snapshots/x86_64-linux-tinfo6/e98971e81129cdfd1c6f69047b1a855bf8841f7fbabf8bdf33f7ca61bd877688/8.10.7/doc/nanovg-0.8.0.0 --dependency=base=base-4.14.3.0 --dependency=bytestring=bytestring-0.10.12.0 --dependency=containers=containers-0.6.5.1 --dependency=text=text-1.2.4.1 --dependency=vector=vector-0.12.3.1-2QhxFayEJrmJ3PNYTgAmQ3 -f-examples -f-gl2 -f-gles3 -fstb_truetype --exact-configuration --ghc-option=-fhide-source-paths
Process exited with code: ExitFailure 1
How do I "stack clean"?
stack purge
! There also should be a .stack-work
dir in the project root, and a .stack
dir in your home. You should be able to delete both of them. glew should be present within the docker image.
Myself I was also a bit surprised that stack runs docker which runs stack here, but apparently that's how the haskell tool kit works here. The main problem I suppose is having to deal with lots of permission issues that stack can avoid for you and make your container builds much simpler. In case you're interested, I guess this here is a way better explanation: https://www.fpcomplete.com/blog/2015/08/stack-docker/
$ stack purge
$ stack --docker-image=futr purge
$ stack --docker-image=futr build
free > using precompiled package
invariant > using precompiled package
modern-uri > using precompiled package
these > using precompiled package
x509-store > using precompiled package
nanovg > configure
adjunctions > using precompiled package
strict > using precompiled package
x509-system > using precompiled package
x509-validation> using precompiled package
kan-extensions > using precompiled package
nanovg > Configuring nanovg-0.8.0.0...
aeson > using precompiled package
nanovg > Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: The pkg-config package 'glew' is
nanovg > required but it could not be found.
nanovg >
Progress 12/24
Clearly purge did not purge much.
$ rm -rf .stack-work/ ~/.stack/
worked in that it now took long to compile again but with the same error message. No running futr here.
That's weird, because when I remove the secp256k1 stuff from the Dockerfile and test locally, it tells me that it cannot compile because of missing lib. When I enable it again, it works fine. As glew is also getting installed in this Dockerfile and it works fine for me, I don't know how to reproduce the issue right now. Hopefully I have an idea soon, but no answer right now, I'm sorry.
For documentation purpose:
I did the following Kubuntu 20.04 LTS:
docker build . -t futr
stack --docker-image=futr build
My output is this
[27 of 27] Compiling Main
Linking .stack-work/dist/x86_64-linux-dk853872affa0c9da5a270995af6cc5128/Cabal-3.2.1.0/build/futr/futr ...
futr > copy/register
Installing executable futr in /home/sasa/code/futr/.stack-work/install/x86_64-linux-dk853872affa0c9da5a270995af6cc5128/2e07fb79cb4fb1fce2ab8741c0705c578651ea3c32505c59f9bb1e765d799934/8.10.7/bin
When I run the binary I get this output:
./futr: error while loading shared libraries: libsecp256k1.so.0: cannot open shared object file: No such file or directory
Seems like a static compiling issue. No luck again, it's late, maybe next time.
For the symlink workaround in the
Dockerfile
see stack issue here: https://github.com/commercialhaskell/stack/issues/5768