serverless-haskell
serverless-haskell copied to clipboard
Build failures after switching to `haskell:stretch`
Today I tried upgrading from serverless-haskell from 0.12.5 to 0.12.6
With 0.12.5 my lambdas are building fine. But after upgrade to 0.12.6 I started getting failures like this:
...
postgresql-libpq > Configuring postgresql-libpq-0.9.4.2...
postgresql-libpq > setup: The program 'pg_config' is required but it could not be found.
...
...
-- While building package postgresql-libpq-0.9.4.2 (scroll up to its section to see the error) using:
...
Error ---------------------------------------------------
...
Error: Error when running Stack: exit code: 1
Stack command: stack --docker --docker-image haskell:stretch --no-nix build
at new ProcessError (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:76:28)
at ServerlessPlugin.runStack (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:158:19)
at /home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:276:19
at Array.forEach (<anonymous>)
at ServerlessPlugin.buildHandlers (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:254:34)
at PluginManager.invoke (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/classes/PluginManager.js:576:20)
at async PluginManager.run (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/classes/PluginManager.js:634:7)
at async Serverless.run (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/Serverless.js:427:5)
at async /home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/scripts/serverless.js:650:9
I suspect the reason might be this:
My application depends on postgresql-simple
, which in turn depends on libpq-devel
C library.
This dependency was probably present in the fpco/stack-build:lts-13.30
, but is no longer provided by the new haskell:stretch
image:
$ docker run -it fpco/stack-build:lts-13.30 /bin/bash
root@f4a5ce57efce:/# pkg-config --list-all | grep libpq
libpq libpq - PostgreSQL libpq library
$ docker run -it haskell:stretch /bin/bash
root@91a83277f13e:/# pkg-config --list-all | sort
form form - ncurses 6.0 add-on library
menu menu - ncurses 6.0 add-on library
ncurses ncurses - ncurses 6.0 library
ncurses++ ncurses++ - ncurses 6.0 add-on library
panel panel - ncurses 6.0 add-on library
sqlite3 SQLite - SQL database engine
tic tic - ncurses 6.0 add-on library
tinfo tinfo - ncurses 6.0 terminal interface library
zlib zlib - zlib compression library
haskell:stretch
is an image with old enough glibc that is compatible with AWS Lambda environment, but new enough to run new GHC in stackage LTS 17.
An easy way forward is to add an option to provide your own Docker image in the configuration, and use it when building.
Another option to explore is utilizing Lambda Docker support and building complete Docker images by the plugin (though that would also need a base image, and possibly more configuration).
Let me know if you're interested in adding any of the above!
Thanks for the reply. Just to clarify, by
Let me know if you're interested in adding any of the above!
you mean if I'm interested in implementing it or if I'm interested in you implementing it? :smile: I'm not really confident enough in TS/JS to implement it, but making the builder image configurable sounds like good enough for our purposes.
Either, but thanks for the reply :) I can't promise any timelines for this, but a workaround for you can be to run the whole build in a Docker image of your choice and disable Docker in the plugin.