Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Incorrect find usage in alpine #72

Open
bazzilio opened this issue Aug 22, 2018 · 8 comments
Open

Incorrect find usage in alpine #72

bazzilio opened this issue Aug 22, 2018 · 8 comments

Comments

@bazzilio
Copy link

bazzilio commented Aug 22, 2018

In alpine linux, used mostly for docker, Call to find failed, because in alpine find can't search in multiple locations.

gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1

It would be better to split find calls, like this:

find /usr/bin params && find  /usr/local/bin params && etc.

Full log attached.had
The problem had gone after installing postgresql-dev package.

Steps to reproduce:

  1. build container with a Dockerfile
FROM node:8-alpine
RUN npm install
  1. Error would happen, if node-gyp used

node_gyp_error.txt

@hawkesn
Copy link

hawkesn commented Mar 5, 2019

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?

@hawkesn
Copy link

hawkesn commented Mar 5, 2019

I managed to resolve it with the following:

RUN apk --no-cache add make python gcc postgresql-dev g++
RUN yarn install

@sehrope
Copy link

sehrope commented Mar 5, 2019

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).

@lukasa1993
Copy link

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 ?

@charmander
Copy link
Collaborator

@lukasa1993 yes (try it!)

@jorinvo
Copy link

jorinvo commented Jul 20, 2021

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.

@charmander
Copy link
Collaborator

@jorinvo You shouldn’t need the full postgresql-dev, just libpq.

@jorinvo
Copy link

jorinvo commented Jul 21, 2021

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants