Pkg-config, Libsecret error on Alpine docker container when npm install is run
thxmike opened this issue · comments
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
Pkg-config Libsecret error on Alpine
Steps to Reproduce
- Leveraging the following image container node:14.16.0-alpine
- Then installing python, pkgconfig, libsecret
- npm install with the following library in package.json: @azure/identity
Expected behavior:
No failures in the npm install log
Actual behavior:
2021-03-25T15:28:30.0300381Z > keytar@7.4.0 build /application/node_modules/keytar
2021-03-25T15:28:30.0300959Z > node-gyp rebuild
2021-03-25T15:28:30.0301139Z
2021-03-25T15:28:30.9989134Z �[91mPackage libsecret-1 was not found in the pkg-config search path.
2021-03-25T15:28:30.9990435Z Perhaps you should add the directory containing `libsecret-1.pc'
2021-03-25T15:28:30.9991221Z to the PKG_CONFIG_PATH environment variable
2021-03-25T15:28:30.9992304Z Package 'libsecret-1', required by 'virtual:world', not found
2021-03-25T15:28:30.9993730Z gyp: Call to 'pkg-config --cflags libsecret-1' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
2021-03-25T15:28:31.0102855Z �[0m�[91mgyp�[0m�[91m ERR! configure error
2021-03-25T15:28:31.0120274Z �[0m�[91mgyp �[0m�[91mERR! �[0m�[91mstack Error: `gyp` failed with exit code: 1
2021-03-25T15:28:31.0121625Z gyp ERR!�[0m�[91m stack�[0m�[91m at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
2021-03-25T15:28:31.0123299Z �[0m�[91mgyp �[0m�[91mERR! �[0m�[91mstack at ChildProcess.emit (events.js:315:20)
2021-03-25T15:28:31.0124136Z gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
2021-03-25T15:28:31.0140885Z �[0m�[91mgyp ERR! System�[0m�[91m Linux 5.4.0-1041-azure
2021-03-25T15:28:31.0141924Z �[0m�[91mgyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
2021-03-25T15:28:31.0142803Z �[0m�[91mgyp �[0m�[91mERR!�[0m�[91m cwd /application/node_modules/keytar
2021-03-25T15:28:31.0143566Z �[0m�[91mgyp�[0m�[91m ERR!�[0m�[91m �[0m�[91mnode -v�[0m�[91m v14.16.0
2021-03-25T15:28:31.0144298Z �[0m�[91mgyp ERR!�[0m�[91m �[0m�[91mnode-gyp -v�[0m�[91m v5.1.0
2021-03-25T15:28:31.0144939Z �[0m�[91mgyp ERR!�[0m�[91m not ok
2021-03-25T15:28:31.0246722Z �[0m�[91mnpm�[0m�[91m ERR! code ELIFECYCLE
2021-03-25T15:28:31.0247454Z �[0m�[91mnpm�[0m�[91m ERR! errno 1
2021-03-25T15:28:31.5310205Z �[0m�[91mnpm ERR! keytar@7.4.0 build: `node-gyp rebuild`
2021-03-25T15:28:31.5315773Z npm ERR! Exit status 1
2021-03-25T15:28:31.5316166Z npm ERR!
2021-03-25T15:28:31.5316562Z npm ERR! Failed at the keytar@7.4.0 build script.
2021-03-25T15:28:31.5317131Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-03-25T15:28:31.5318257Z �[0m�[91mnpm�[0m�[91m WARN Local package.json exists, but node_modules missing, did you mean to install?
2021-03-25T15:28:31.5319133Z �[0m�[91m
2021-03-25T15:28:31.5319817Z �[0m�[91mnpm ERR!�[0m�[91m A complete log of this run can be found in:
2021-03-25T15:28:31.5320602Z npm ERR! /root/.npm/_logs/2021-03-25T15_28_31_028Z-debug.log
Reproduces how often:
Every time
Versions
This is running on OS Linux Alpine. The packages are
"@azure/identity": "^1.2.4",
"@azure/keyvault-secrets": "^4.1.0"
Which have a dependency on keytar 7.4.0
Additional Information
Here is a copy of the dockerfile
FROM node:14.16.0-alpine
LABEL team=gravity-diagnostics
#ENV PORT=80,443
ENV PORT=3000
ENV AZURE_KEY_STORE_URI=""
ENV AZURE_CLIENT_ID=""
ENV AZURE_CLIENT_SECRET=""
ENV AZURE_TENANT_ID=""
# Install Build Dependencies
RUN apk --no-cache --virtual build-dependencies add
ENV PYTHONUNBUFFERED=1
RUN echo "**** install Python ****" && \
apk add --no-cache python3 && \
if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi
# && \
# \
# echo "**** install pip ****" && \
# python3 -m ensurepip && \
# rm -r /usr/lib/python*/ensurepip && \
# pip3 install --no-cache --upgrade pip setuptools wheel && \
# if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi
#EXPOSE 443
RUN apk add --no-cache pkgconfig
RUN apk add --no-cache libsecret
RUN mkdir -p /application && chown -R node:node /application
RUN mkdir -p /application/node_modules && chown -R node:node /application/node_modules
RUN mkdir -p /application/bin && chown -R node:node /application/bin
RUN which python
WORKDIR /application
COPY . /application
RUN npm install --global node-gyp
# Have to prebuild node modules and make part of the image since the azure hosts are missing python for building.
# RUN npm config set python "/usr/bin/python"
# RUN env PATH="/usr/bin:$PATH" PYTHON=/usr/bin/python
RUN npm install
RUN node_modules/.bin/tsc
COPY --chown=node:node . .
RUN apk del python3
RUN apk del build-dependencies
RUN apk del pkgconfig
EXPOSE 3000
USER node
CMD [ "ash", "deployment.sh" ]
Based on #354 I think you need these packages:
node-keytar/.github/workflows/ci.yml
Line 107 in d820296
libsecret-dev
is a different package to libsecret
I've made a bunch of changes to how releases are made and am waiting to confirm we're good before including the prebuild artifacts from #354 in a release, which should simplify things for Alpine users of this package.
Thanks for the feedback, I added the packages you suggested and it runs npm install with no errors. Only warnings which I can live with.
Here are the warnings for reference:
#19 88.73 make: Entering directory '/application/node_modules/keytar/build'
#19 88.74 CXX(target) Release/obj.target/keytar/src/async.o
#19 94.01 CXX(target) Release/obj.target/keytar/src/main.o
#19 98.72 CXX(target) Release/obj.target/keytar/src/keytar_posix.o
#19 100.8 ../src/keytar_posix.cc: In function 'keytar::KEYTAR_OP_RESULT keytar::SetPassword(const string&, const string&, const string&, std::string*)':
#19 100.8 ../src/keytar_posix.cc:38:9: warning: missing sentinel in function call [-Wformat=]
#19 100.8 38 | NULL); // End of arguments.
#19 100.8 | ^
#19 100.8 ../src/keytar_posix.cc: In function 'keytar::KEYTAR_OP_RESULT keytar::GetPassword(const string&, const string&, std::string*, std::string*)':
#19 100.8 ../src/keytar_posix.cc:61:9: warning: missing sentinel in function call [-Wformat=]
#19 100.8 61 | NULL); // End of arguments.
#19 100.8 | ^
#19 100.8 ../src/keytar_posix.cc: In function 'keytar::KEYTAR_OP_RESULT keytar::DeletePassword(const string&, const string&, std::string*)':
#19 100.8 ../src/keytar_posix.cc:88:9: warning: missing sentinel in function call [-Wformat=]
#19 100.8 88 | NULL); // End of arguments.
#19 100.8 | ^
#19 100.8 ../src/keytar_posix.cc: In function 'keytar::KEYTAR_OP_RESULT keytar::FindPassword(const string&, std::string*, std::string*)':
#19 100.8 ../src/keytar_posix.cc:112:9: warning: missing sentinel in function call [-Wformat=]
#19 100.8 112 | NULL); // End of arguments.
#19 100.8 | ^
#19 102.4 SOLINK_MODULE(target) Release/obj.target/keytar.node
#19 102.7 COPY Release/keytar.node
#19 102.7 make: Leaving directory '/application/node_modules/keytar/build'
#19 104.0 npm WARN orders-api@0.0.12 No repository field.
Here is my final dockerfile for reference who may need it for the alpine container running node
FROM node:14.16.0-alpine
LABEL team=gravity-diagnostics
#ENV PORT=80,443
ENV PORT=3000
ENV AZURE_KEY_STORE_URI=""
ENV AZURE_CLIENT_ID=""
ENV AZURE_CLIENT_SECRET=""
ENV AZURE_TENANT_ID=""
# Install Build Dependencies
RUN apk --no-cache --virtual build-dependencies add
ENV PYTHONUNBUFFERED=1
RUN echo "**** install Python ****" && \
apk add --no-cache python3 && \
if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi
# && \
# \
# echo "**** install pip ****" && \
# python3 -m ensurepip && \
# rm -r /usr/lib/python*/ensurepip && \
# pip3 install --no-cache --upgrade pip setuptools wheel && \
# if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi
#EXPOSE 443
RUN apk add --no-cache pkgconfig
RUN apk add --no-cache libsecret-dev
RUN apk add --no-cache g++ make
RUN mkdir -p /application && chown -R node:node /application
RUN mkdir -p /application/node_modules && chown -R node:node /application/node_modules
RUN mkdir -p /application/bin && chown -R node:node /application/bin
RUN which python
WORKDIR /application
COPY . /application
RUN npm install --global node-gyp
# Have to prebuild node modules and make part of the image since the azure hosts are missing python for building.
# RUN npm config set python "/usr/bin/python"
# RUN env PATH="/usr/bin:$PATH" PYTHON=/usr/bin/python
RUN npm install
RUN node_modules/.bin/tsc
COPY --chown=node:node . .
RUN apk del python3
RUN apk del build-dependencies
RUN apk del pkgconfig
RUN apk del make
RUN apk del g++
EXPOSE 3000
USER node
CMD [ "ash", "deployment.sh" ]