Open bazzilio opened 6 years ago
I'm running into this exact issue right now with
FROM node:11.10.1-alpine
Installing postgresql-dev package did not resolve it for me Any ideas on how to resolve it?
I managed to resolve it with the following:
RUN apk --no-cache add make python gcc postgresql-dev g++
RUN yarn install
That makes sense. Alpine images are slimmed down to contain the bare minimum so they likely do not have any of the build tools needed to compile the native driver (i.e. g++ and the libpq headers).
I managed to resolve it with the following:
RUN apk --no-cache add make python gcc postgresql-dev g++ RUN yarn install
after this can be node_modules copied into another alpine linux ( e.g docker multistage builds) to not have all those apk dependencies required ?
@lukasa1993 yes (try it!)
Hi there, thanks for this thread everyone! This seems to be the only documentation available on the internet on how to get pg-native
running in Alpine containers :)
This is what worked for us:
In the base image we have
RUN apk add --no-cache python build-base gcc g++ postgresql-dev
RUN npm ci
and in the slimmed-down production stage of the the multi-stage image we then only need
RUN apk add --no-cache libpq
So it works with less dependencies, but libpq
is still required, even after npm install
.
Note that this is tested through Slonik.
Without libpq
in the final container, Slonik logs pg-native module is not found
.
Edit: I adjusted the code above to reflect the insights from below: In production only libpq
and not postgresql-dev
is needed.
@jorinvo You shouldn’t need the full postgresql-dev
, just libpq
.
@charmander thank you for the reply! I tested it and, indeed, libpq
is enough for production, thanks! Interestingly it is not enough for npm install
. I adjusted the above comment accordingly for reference.
In alpine linux, used mostly for docker, Call to find failed, because in alpine find can't search in multiple locations.
It would be better to split find calls, like this:
Full log attached.had The problem had gone after installing postgresql-dev package.
Steps to reproduce:
node_gyp_error.txt