4

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?

Urs
  • 4,984
  • 7
  • 54
  • 116
Said Saifi
  • 1,995
  • 7
  • 26
  • 45

3 Answers3

4

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
Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
user2915097
  • 30,758
  • 6
  • 57
  • 59
  • thank you I am creating my image from a centos7 base image and I don't have apt installed so I am getting apt-get command not found. do you know what should I do? – Said Saifi Oct 04 '16 at 06:50
  • If you don't know centos, use ubuntu as base image! Centos uses "yum" as "apt-get" , should work similarly. – Thomas Decaux Oct 04 '16 at 07:03
3

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
VladoDemcak
  • 4,893
  • 4
  • 35
  • 42
1

First of All you need to check that bower is installed globally in your machine or not.? Than you can install package with bower.

you can install With command : npm install bower -g

Rishi Raj
  • 117
  • 1
  • 7