2016-10-04 185 views
1

我正在使用go作爲我的應用程序前端的後端和角度js,並且能夠運行前端,因此我應該先運行bower安裝。如何在Dockerfile中運行bower安裝?

注意:我從一個centos7基礎圖像構建我的圖像。

我試圖在運行命令將其添加在泊塢窗文件,因爲這

WORDIR ./Frontend 
RUN bower install 

我得到了一個錯誤:

/bin/sh: bower: command not found 

是否有人知道我怎麼能解決這個問題?

+0

它看起來像'bower'沒有安裝在你的搬運工圖像 – Rudis

+0

@Rudis肯定的,但如何能如果我使用的是centos7基本映像,我會安裝它嗎? – user6638204

+0

如何在centos7上安裝bower描述http://stackoverflow.com/a/32724832/1214948 – Rudis

回答

1

這是完整的例子如何爲碼頭工人在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 

,並在建築這個碼頭形象的階段,你應該看到像下面這樣的東西。它表明(在構建階段)您已成功安裝涼亭。

試圖改變幫助安裝也可以增加你的泊塢窗命令 - WORDIR ./Frontend

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 
3

你應該哈弗看看https://github.com/marmelab/docker-bower/blob/master/Dockerfile

我看,除其他事項外

的所有您需要檢查鮑爾是在全球範圍內您的機器或沒有安裝
RUN apt-get install -y -qq npm 

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

# install bower 

RUN npm install --global bower 
+0

謝謝我從centos7基礎映像中創建我的映像,並且我沒有安裝apt,因此我正在使用apt-找不到命令。你知道我該怎麼做? – user6638204

+0

如果您不知道centos,請使用ubuntu作爲基礎映像! Centos使用「yum」作爲「apt-get」,應該類似地工作。 –

1

第一? 比你可以安裝包與涼亭。

則可以安裝帶有命令: NPM安裝涼亭-g