运行凉亭安装在docker卷内
上下文
所以我试图执行在docker集装箱内build立一个聚合物项目作为一个卷(要访问它我使用docker run (...) --volume="/var/www/html:/var/www/html" --volumes-from="my-polymer-image-name" my-nginx-image
)。
我尝试执行下面的Dockerfile,但最后声明了音量,但是当我尝试从“my-nginx-container”( docker exec -ti my-nginx-image-name /bin/sh
) 。
所以我想在使用之前我必须声明音量。
问题
但是当我试图安装我的bower组件时,我注意到没有创buildbower_components
目录。
######################################################## # Dockerfile to build Polymer project and move to server # Based on oficial node Dockerfile ######################################################## FROM node:6 VOLUME /var/www/html # Install polymer and bower RUN npm install -g \ polymer-cli \ bower # Add project to a temp folder to build it RUN mkdir -p /var/www/html/temp COPY . /var/www/html/temp WORKDIR /var/www/html/temp RUN ls -la RUN bower install --allow-root # here is where I try to build my project RUN polymer build # Move to release folder WORKDIR /var/www/html RUN mv /var/www/html/temp/build/unbundled/* /var/www/html RUN bower install --allow-root # Remove temporary content RUN rm -rf /var/www/html/temp
Docker镜像构build完成后的卷装入。
在Docker文件的最后一行添加
ENTRYPOINT ["/bin/bash", "/etc/entrypoint.sh"]
使用这样的entripoint脚本。
#!/bin/bash set -e #if error bash script will exit and stop docker image cd /var/www/html/ bower install --allow-root polymer build mv /var/www/html/temp/build/unbundled/* /var/www/html rm -rf /var/www/html/temp