awslabs / app-development-for-backstage-io-on-aws

A developer portal to meet your Enterprise needs. Fast, secure, and at-scale.
https://opaonaws.io/
Apache License 2.0
160 stars 28 forks source link

The Dockerfile won't build. Missing Python dependency? #15

Closed m0un10 closed 8 months ago

m0un10 commented 1 year ago

The make deploy-prereq step fails with the following...

#0 64.37 gyp ERR! find Python 
#0 64.37 gyp ERR! find Python Python is not set from command line or npm configuration
#0 64.37 gyp ERR! find Python Python is not set from environment variable PYTHON
#0 64.37 gyp ERR! find Python checking if "python3" can be used
#0 64.37 gyp ERR! find Python - "python3" is not in PATH or produced an error
#0 64.37 gyp ERR! find Python checking if "python" can be used
#0 64.37 gyp ERR! find Python - "python" is not in PATH or produced an error
#0 64.37 gyp ERR! find Python 
#0 64.37 gyp ERR! find Python **********************************************************
#0 64.37 gyp ERR! find Python You need to install the latest version of Python.
#0 64.37 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#0 64.37 gyp ERR! find Python you can try one of the following options:
#0 64.37 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#0 64.37 gyp ERR! find Python   (accepted by both node-gyp and npm)
#0 64.37 gyp ERR! find Python - Set the environment variable PYTHON
#0 64.37 gyp ERR! find Python - Set the npm configuration variable python:
#0 64.37 gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#0 64.37 gyp ERR! find Python For more information consult the documentation at:
#0 64.37 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#0 64.37 gyp ERR! find Python **********************************************************
#0 64.37 gyp ERR! find Python 
#0 64.37 gyp ERR! configure error 
#0 64.37 gyp ERR! stack Error: Could not find any Python installation to use
#0 64.37 gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#0 64.37 gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#0 64.37 gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#0 64.37 gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#0 64.37 gyp ERR! stack     at exithandler (node:child_process:427:5)
#0 64.37 gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:439:5)
#0 64.37 gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#0 64.37 gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
#0 64.37 gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
#0 64.37 gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

The prior yarn tsc && yarn build:all step worked fine.

yarn run v1.22.19
$ tsc
✨  Done in 3.32s.
yarn run v1.22.19
$ backstage-cli repo build --all
Building packages
Building apps
Loaded config from app-config.yaml
  350.79 kB  dist/static/8512.948341c9.chunk.js
  347.19 kB  dist/static/vendor.4a094630.js
...
Building backends
Moving backend into dist workspace
Moving app into dist workspace
✨  Done in 21.50s.

Perhaps the upstream Docker image or another dependency has changed, if this used to work? Or, maybe it don't work on Arm?

Versions

macOS Ventura 13.4

Darwin omitted.local 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 arm64

Docker 24.0.2

Node: v18.14.0

awsjim commented 1 year ago

Hi @m0un10 - thanks for reporting this issue. Backstage recently released v1.15.0 and it appears that there's a breaking change that now requires python in the image build process (see https://backstage.io/docs/releases/v1.15.0/#breaking-scaffolder-build-requirements).

I'm working on an update and expect to have something available shortly which will pin Backstage to a tested version. In the meantime, if you want to test a workaround for Backstage 1.15.0, then you can try adding the following code to the config/Dockerfile file. I haven't tested this yet, so I don't know if there will be other issues:

...
FROM --platform=linux/amd64 node:18-bullseye-slim

+ # Install required pre-reqs for node_module dependencies
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
+   apt-get update && \
+   apt-get install -y --no-install-recommends python3 build-essential && \
+   yarn config set python /usr/bin/python3

# From here on we use the least-privileged `node` user to run the backend.
USER node
...
z-sourcecode commented 8 months ago

fixed.