I need run npm rebuild node-sass --force
inside my docker container
But i got an error (even after i install python already)
Error: Can't find Python executable "python", you can set the PYTHON env variable.
This is my Dockerfile
FROM node:8.16.0-alpine
RUN mkdir /app
WORKDIR /app
# --no-cache: download package index on-the-fly, no need to cleanup afterwards
# --virtual: bundle packages, remove whole bundle at once, when done
RUN apk --no-cache --virtual build-dependencies add \
python \
make \
g++ \
bash \
&& npm install \
&& apk del build-dependencies
RUN npm install -g nodemon
COPY package.json package.json
COPY client/package.json client/package.json
RUN npm install
RUN npm run install:client
RUN npm uninstall node-sass && npm install node-sass
RUN npm rebuild node-sass --force
COPY . .
LABEL maintainer="Varis Darasirikul"
VOLUME ["/app/public"]
CMD npm run dev
This my docker-compose
version: '3'
services:
web:
build: '.'
container_name: node-web
# env_file:
# - '.env'
ports:
- '80:8000'
- '5000:5000'
- '3000:3000'
volumes:
- '.:/app'
networks:
- front-tier
- back-tier
# depends_on:
# - redis
# - db
networks:
front-tier:
back-tier:
Even when i run
docker-compose up --build --force-recreate
Still not working
How to fix this?
Thanks!
The problem is that Python is simply not installed.
Your parent image, node:8.16.0-alpine
doesn't include Python. You can verify this:
> docker run -it node:8.16.0-alpine sh
/ # python
sh: python: not found
The misunderstanding might come from the fact that you are temporarily installing python on this line:
RUN apk --no-cache --virtual build-dependencies add \
python \
...
It's added to the virtual package build-dependencies
, but just after npm install
completes, you run apk del build-dependencies
which removes Python again!
Just move the line where you uninstall build-dependencies
to after you have done all npm rebuild
stuff and I think it will work.
Because you are using alpine
image which is a small image that doesn't include python
. You can install python
by running apk add
and remove it after you have installed node modules.
FROM node:alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install \
&& apk del .gyp
More read: https://github.com/nodejs/docker-node/issues/282
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With