Seiji Hirao
Seiji Hirao

Reputation: 311

Running bower install inside a docker volume

Context

So I'm trying to execute build a polymer project inside a docker container as a volume (to access it I'm using docker run (...) --volume="/var/www/html:/var/www/html" --volumes-from="my-polymer-image-name" my-nginx-image).

And I tried execute the following Dockerfile, but declaring the volume last, but the volume was empty when I tried to access it from "my-nginx-container" (docker exec -ti my-nginx-image-name /bin/sh).

So I thought I had to declare the volume before using using it.

Problem

But when I tried to install my bower components, I noticed that no bower_components directory was being created.

########################################################
# 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

Upvotes: 2

Views: 1050

Answers (1)

evtuhovdo
evtuhovdo

Reputation: 334

Volume mount when docker image build done.

in last row in Docker file add

ENTRYPOINT ["/bin/bash", "/etc/entrypoint.sh"]

Use entripoint script like this.

#!/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

Upvotes: 1

Related Questions