Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run bower install inside a Dockerfile?

I am using go for the backend and angular js for the frontend of my application, and to be able to run the frontend I should run bower install first.

note: I am building my image from a centos7 base image.

I tried adding it in the docker file in the RUN command as this

WORKDIR ./Frontend
RUN bower install

I got an error:

/bin/sh: bower: command not found

does anybody knows how can I solve this?

like image 882
Said Saifi Avatar asked Mar 12 '23 00:03

Said Saifi


2 Answers

you should haver a look at https://github.com/marmelab/docker-bower/blob/master/Dockerfile

I see, among other things

RUN apt-get install -y -qq npm

RUN ln -s /usr/bin/nodejs /usr/bin/node

# install bower

RUN npm install --global bower
like image 118
user2915097 Avatar answered Mar 13 '23 17:03

user2915097


This is full example how to install bower for docker with centos

Dockerfile

FROM centos

RUN useradd -ms /bin/bash bower
RUN yum install -y gcc-c++ make
RUN curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
RUN yum install -y nodejs

# install bower
RUN npm install --global bower

USER bower

#this should show bower help - try to use install instead
RUN bower help

and in the building phase of this docker image you should see something like below. Its indicate (in the build phase) that you successfully installed bower.

Try to change help to install and also add your docker commands - WORDIR ./Frontend etc.

Step 8 : RUN bower help
---> Running in 2afd81510166
Usage:
bower <command> [<args>] [<options>]
Commands:
cache                   Manage bower cache
help                    Display help information about Bower
home                    Opens a package homepage into your favorite browser
like image 40
VladoDemcak Avatar answered Mar 13 '23 18:03

VladoDemcak