Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile and issue making work bower install

Im trying to exec bower install on node:4.1.2 docker container from the dockerfile.

Part of my dockerfile is like this:

#Install bower to command line
RUN npm install -g bower

# Define the host folder that will contain the code
WORKDIR /application

# Copy src to application host folder**
ADD . /application

# RUN move to /application/public/webapp where there is a bower.json file and install it**
RUN cd public/webapp && bower install --allow-root --config.interactive=false

ENTRYPOINT ["npm"]
CMD ["start"]

I build it and up it.

This dockerfile does not build the bower_components folder despite of showing:

Step 9 : RUN cd public/webapp && bower install --allow-root --config.interactive=false
 ---> Running in 937ad6c21887
/application/public/admintool
bower angular#1.4.7         not-cached git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7            resolve git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7           download https://github.com/angular/bower-angular/archive/v1.4.7.tar.gz
bower angular#1.4.7            extract archive.tar.gz
bower angular#1.4.7           resolved git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7            install angular#1.4.7

angular#1.4.7 bower_components/angular

If I get into the container, bower is recognized as a command (it installed it). Running bower install from /application/public/webapp works if Im inside the container. From dockerfile it just does not do anything. Neither it complains.

Does anyone knows why?

like image 342
kitimenpolku Avatar asked Nov 09 '22 02:11

kitimenpolku


1 Answers

Are you perhaps mounting a volume from your host into the container through your docker-compose.yml file or the -v parameter in your docker run command?

I ask because you mentioned you don't have bower installed on your machine, so you presumably don't have the bower_components folder in the host copy of your codebase. If you then run your container and mount the volume containing the source on your host into the container then the bower_components folder would be lost, explaining why it seems to disappear from the container.

I would first test to see if this is indeed the problem by not mounting any volumes from your host and seeing if the bower_components folder then remains after you build and run the container. You could then install bower on your host and run bower install so the mounted volume doesn't cause issues while you're in development.

like image 106
Scott Covert Avatar answered Nov 15 '22 07:11

Scott Covert