How to add npm into docker project based on apache? Hello,
How correctly add npm / nodejs to my php 7.2 / laravel 5 docker project based on php:7.2-apache ?
In my web/Dockerfile.yml I added line with " nodejs ":
FROM php:7.2-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
nano \
libgmp-dev \
libldap2-dev \
netcat \
sqlite3 \
nodejs \
git \
libsqlite3-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
and running command :
docker-compose up -d --build
I did not get any errors during installation and I entered the bash, but failed testing
$ docker-compose exec web bash
root@beef5dec0a0b:/var/www/html# npm -v
bash: npm: command not found
root@beef5dec0a0b:/var/www/html# node -v
bash: node: command not found
I tried to add npm in the listing above, but got error that no candidate found...
Thanks !
Inside your docker:
apt-get install git-core curl build-essential openssl libssl-dev \
&& git clone https://github.com/nodejs/node.git \
&& cd node \
&& ./configure \
&& make \
&& sudo make install
Thank you for your feedback!
I modified my web/Dockerfile.yml file as :
FROM php:7.2-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
nano \
git-core \
curl \
build-essential \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
sqlite3 \
libsqlite3-dev \
&& git clone https://github.com/nodejs/node.git \
&& cd node \
&& ./configure \
&& make \
&& sudo make install \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
and running
docker-compose up -d --build
command after long output I got error :
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Cloning into 'node'...
Checking out files: 100% (31121/31121), done.
./configure: 4: exec: python: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev nano git-core curl build-essential openssl libssl-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && git clone https://github.com/nodejs/node.git && cd node && ./configure && make && sudo make install docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif && a2enmod rewrite' returned a non-zero code: 127
Have I to add some package with python ? Which ?
You're almost there, just need a little change:
drop the && before the git clone command.
change this:
&& git clone https://...
into this:
git clone https://...
Please sign in or create an account to participate in this conversation.