0

I'm trying to run a script but nodejs can't find python for some reason. I have tried reinstalling python, reinstalling nodejs, reinstalling my OS, running (and rebooting afterwards): export PYTHON="$(which python)", export PYTHON="$(which python3)" (which python does return the right path), npm config set python /usr/bin/python3.9, npm config set python "/usr/bin/python3.9" and export PYTHONPATH="$(which python)" but nothing has worked. I'm running 64 bit lite raspberry OS off a raspberry pi 4. I installed nodejs and python with sudo apt install python/npm/nodejs. Context

Error

The script:

#!/bin/bash

set -xe

cd client
rm -rf .next
yarn
yarn build 
cd ..

bash ./bundle-client.sh
docker build --network=host -t clipface:latest .
rm client/docker-bundle.tgz

I tried adding --python="/usr/bin/python3.9" to line 7 and 8 but it makes no difference. I can't add it to line 12 because docker doesn't have a --python switch. Line 12 is when the error occurs

Dockerfile:

FROM node:alpine

# App setup

ADD client/docker-bundle.tgz /

WORKDIR /app

RUN yarn --prod

# Configuration

ENV NODE_CONFIG_DIR=/config
ENV NODE_ENV production
ENV PORT 80
EXPOSE 80
VOLUME /clips
VOLUME /config

CMD yarn start -p ${PORT}

New errors after adding RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python to Dockerfile: https://pastebin.com/eKPZzPSk

tired
  • 1
  • 1
  • 2
  • Your error is happening in **docker build**. That (and docker in general) doesn't use any envvars you have set in your shell; it only uses envvars set _in Dockerfile or the (source) image_. And docker only runs software installed or mounted _in the container_ not in the host -- and at least `node:lts-alpine` (which I use) does in fact not have python, which seems like a mistake since as you've found `yarn` uses it. – dave_thompson_085 Feb 27 '22 at 04:53
  • How can I fix it then? I tried adding `RUN apt-get update -y` and `RUN apt-get install -y python3` to the dockerfile but I get errors (apt-get not found) no matter where I put it. I edited the post to include the dockerfile if it's needed – tired Feb 27 '22 at 09:58
  • ohh I had to use `RUN apk add`. I think python might work but I get different errors now. I updated the question with the new errors but I'm not sure if I have to ask it as a new question instead – tired Feb 27 '22 at 10:17

0 Answers0