I am working on an existing project that was built by Droopler distribution and docker4drupal. As per Droopler distribution documentation, it requires npm and gulp to compiled sass easily and docker4drupal don't have it by default.
I tried to install in the container by sudo apt-get install npm and it says:
sudo: apt-get: command not found
Is there any way to install npm and gulp in docker4drupal for my existing project?
I am able to install npm & gulp, access php container and install those.
access php container docker-compose exec php bash
install npm sudo apk update && sudo apk add npm
install gulp globally sudo npm install -g gulp
This is how I do it, maybe there is a better way.
Reference: Install npm and gulp
Related
This is my Dockerfile:
RUN mkdir /mcvitty
COPY . /mcvitty
RUN cd /mcvitty &&\
npm install -g gulp#3.9.1 &&\
npm link gulp --force &&\
npm install jshint#2.9.5 &&\
npm install gulp-jshint#2.0.4 &&\
npm install gulp-sass#3.1.0 &&\
npm install gulp-concat#2.6.1 &&\
npm install gulp-uglify#3.0.0 &&\
npm install gulp-rename#1.2.2 &&\
npm install gulp-minify-css#1.2.4 &&\
npm install gulp-image-resize#0.13.0
RUN gulp
RUN gulp resize-images
Whenever I run my container I get the following error:
[08:35:34] Local gulp not found in /
[08:35:34] Try running: npm install gulp
The command '/bin/sh -c gulp' returned a non-zero code: 1
Adding
npm install gulp#3.9.1
to have a local gulp, as suggested by someone does not work either.
Any suggestion?
I have Gulp running in a container. The main differences are that I set a working directory:
RUN mkdir /mcvitty
WORKDIR /mcvitty
COPY . /mcvitty
I don't run npm link gulp, either.
If that doesn't work, remove the RUN gulp commands and add them to your docker run command, e.g.
docker run -it --rm --entrypoint '/bin/sh' myimage -c 'gulp && gulp images'
I fixed the problem by CD back into my dir before running gulp:
RUN cd /mcvitty && gulp
I have all this npm stuff in my Dockerfile and it is taking a long time to build my docker image. How can I speed this up, and ideally cache the results? Nothing is changing, so I wouldn't expect this to take such a long time (about 20 seconds now).
FROM python:3.6-alpine
# python stuff
COPY requirements.txt /app/requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r /app/requirements.txt
# npm stuff
RUN apk add --update nodejs-npm
RUN npm init -y
RUN npm i webpack webpack-cli --save-dev
RUN npm i #babel/core babel-loader #babel/preset-env #babel/preset-react babel-plugin-transform-class-properties --save-dev
RUN npm i react react-dom prop-types --save
RUN npm i react-bootstrap bootstrap
RUN npm i weak-key --save
I did try this solution using the COPY package.json but babel and webpack did not seem to like that (and it did not work).
NOTE: I need to use python:3.6-alpine as this is an existing Django application that is integrating React.js
I have to make use of an existing Dockerfile, which generates a docker image from Centos 7. (FROM centos:7 , is the first line in the Dockerfile.)
I need to be able to run 'npm install' and 'npm run' commands within the containers that will be running this image, but npm is not installed. The ways I find online how to install npm on Centos 7 also do not work, as they rely on things such as apt-get which also is not installed in the container. Not having sudo also seems to be an issue.
Is there a way to configure the actual Dockerfile, to build the image, and have npm installed on that image being built? If not - how can I go about installing npm within the docker containers that will run this Centos7 image?
ANSWER: I added this to the Dockerfile:
RUN yum install -y epel-release
RUN yum install -y npm nodejs
CentOS and (and other EL distributions) do not use apt, they use yum (or dnf). Unfortunately, npm isn't packaged in CentOS' normal repos, os you'd have to install the EPEL repo fist:
Simple add a yum call in your Dockerfile:
RUN yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y npm
Is there any way to install Bower Offilne?
I'm trying to install bower but the same is probably being blocked by some proxy, I would need to install offline
I am using the command:
npm install -g bower on cmd and git cmd.
node.js and npm is instaled.
You can download the Bower zip file and install it as described here.
I run this command on AppVeyor:
dotnet publish .\src\ReviewerServices.web -c Release
ReviewerServices.web is the folder containing my .NET MVC app and I want to create all the files to publish on IIS
Unfortunately, what I get is:
locally I get the same error. Do I need to install bower? npm install -g bower?
Ok, I had to install bower and gulp
npm install -g bower
npm install -g gulp
I have solved the problem.
need to install bower and gulp as a global packages.
npm install -g bower
npm install -g gulp