Missing python3 and cpu-feauture (optional) dependencies when doing docker deployment.

See original GitHub issue

Followed this guide an created 2 images with a separate frontend. I get 2 dependencies errors using the provided Dockerfiles (everything out of the box). Issue happens on Backend and frontend. Do I need to install python3 ? it’s not specified on the instructions

[5/5] Building fresh packages… warning Error running install script for optional dependency: "/app/node_modules/cpu-features: Command failed. Exit code: 1 Command: node-gyp rebuild Arguments: Directory: /app/node_modules/cpu-features Output: gyp info it worked if it ends with ok gyp info using node-gyp@5.1.0 gyp info using node@14.18.0 | linux | x64 gyp ERR! find Python gyp ERR! find Python Python is not set from command line or npm configuration gyp ERR! find Python Python is not set from environment variable PYTHON gyp ERR! find Python checking if "python" can be used gyp ERR! find Python - "python" is not in PATH or produced an error gyp ERR! find Python checking if "python2" can be used gyp ERR! find Python - "python2" is not in PATH or produced an error gyp ERR! find Python checking if "python3" can be used gyp ERR! find Python - "python3" is not in PATH or produced an error gyp ERR! find Python gyp ERR! find Python ********************************************************** gyp ERR! find Python You need to install the latest version of Python. gyp ERR! find Python Node-gyp should be able to find and use Python. If not, gyp ERR! find Python you can try one of the following options: gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable" gyp ERR! find Python (accepted by both node-gyp and npm) gyp ERR! find Python - Set the environment variable PYTHON gyp ERR! find Python - Set the npm configuration variable python: gyp ERR! find Python npm config set python "/path/to/pythonexecutable" gyp ERR! find Python For more information consult the documentation at: gyp ERR! find Python https://github.com/nodejs/node-gyp#installation gyp ERR! find Python ********************************************************** gyp ERR! find Python gyp ERR! configure error gyp ERR! stack Error: Could not find any Python installation to use gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47) gyp ERR! stack at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)

Steps to Reproduce

  1. npx @backstage/create-app (Node v14.15.5)
  2. select postgresql as your db, I think it also happens on sqlite
  3. CI is using ubuntu:latest but I also tested it on centos7
  4. docker build . -f packages/backend/Dockerfile --tag backstage
  5. Same error happens when you build the frontend

Backend Dockerfile


FROM node:14-buster-slim

WORKDIR /app
COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz

RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)"

COPY packages/backend/dist/bundle.tar.gz app-config.yaml ./
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz

CMD ["node", "packages/backend", "--config", "app-config.yaml"]

Frontend Dockerfile

FROM node:14-buster AS build

RUN mkdir /app
COPY . /app
WORKDIR /app

RUN yarn install
RUN yarn workspace app build

FROM nginx:mainline

RUN apt-get update && apt-get -y install jq && rm -rf /var/lib/apt/lists/*
COPY --from=build /app/packages/app/dist /usr/share/nginx/html
COPY docker/default.conf.template /etc/nginx/templates/default.conf.template
COPY docker/inject-config.sh /docker-entrypoint.d/40-inject-config.sh
ENV PORT 80

Everything is built using create-app and deployment using docker with a separate image in the frontend.

Yarn.lock has the cpu-feature dependency

cpu-features@0.0.2:
  version "0.0.2"
  resolved "https://registry.yarnpkg.com/cpu-features/-/cpu-features-0.0.2.tgz#9f636156f1155fd04bdbaa028bb3c2fbef3cea7a"
  integrity sha512-/2yieBqvMcRj8McNzkycjW2v3OIUOibBfd2dLEJ0nWts8NobAxwiyw9phVNS6oDL8x8tz9F7uNVFEVpJncQpeA==
  dependencies:
    nan "^2.14.1"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
iverberkcommented, Feb 13, 2022

I’m running into this as well, out of the box installation results in a failed docker build:

#10 73.96 error /app/node_modules/@vscode/sqlite3: Command failed.

and then a lot of node-gyp output trying to find Python.

4reactions
bgutschkecommented, Feb 17, 2022

Since backstage 0.4.19, and swapping out sqlite3 for @vscode/sqlite3, this error now causes the build to fail, presumably because @vscode/sqlite3 is a required (rather than optional) dependency. Installing python, cmake and g++ resolves the issue - I believe this should be documented now that the build fails if these packages are not installed

Having the same problem. But installing python, cmake and g++ in the production image is not really an option, right? It fixes the issue of the dependencies, but then you have compilers in the image which could pose a security risk.

@backstage-team: Any chance that @vscode/sqlite3 will be defined as an optional dependency again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Containerized Python Development - Part 1
One way to manage dependencies is by using a package installer such as pip. For this we need to create a requirements.txt file...
Read more >
Integrating Python Poetry with Docker
It is better to switch the COPY and RUN statement and use --no-root . Using this option, poetry will only install dependencies and...
Read more >
Docker image template for Python applications
The template supports installing Python dependencies based on a number of different configuration mechanisms: A requirements.txt file. Using Poetry's pyproject.
Read more >
PyCharm - Configure an interpreter using Docker Compose
Configuring Docker · Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Docker. · Click Add a docker server...
Read more >
Containers For Deep Learning Frameworks User Guide
DGX™ systems uses Docker containers as the mechanism for deploying deep ... to using containers is that you can install your application, dependencies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found