install bower packages

- renamed `npm_install` function to `install_packages`
 - execute `bower install` if `bower.json` file exists
 - added `SKIP_BOWER_INSTALL` entrypoint control param
 - adds `bower install` to `Dockerfile.tpl`
This commit is contained in:
Sameer Naik
2017-01-18 12:53:13 +05:30
parent 30bfbdbddf
commit e236974fb4
5 changed files with 19 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ services:
- SKIP_DB_WAIT=0
- SKIP_DB_MIGRATION=0
- SKIP_NPM_INSTALL=0
- SKIP_BOWER_INSTALL=0
depends_on:
- mariadb
ports:

View File

@@ -18,6 +18,7 @@ services:
- SKIP_DB_WAIT=0
- SKIP_DB_MIGRATION=0
- SKIP_NPM_INSTALL=0
- SKIP_BOWER_INSTALL=0
depends_on:
- postgresql
ports:

View File

@@ -16,6 +16,7 @@ services:
- SKIP_DB_WAIT=0
- SKIP_DB_MIGRATION=0
- SKIP_NPM_INSTALL=0
- SKIP_BOWER_INSTALL=0
depends_on:
- mongodb
ports:

View File

@@ -85,6 +85,7 @@ add_dockerfile() {
if [[ ! -f Dockerfile ]]; then
cp -r /dist/Dockerfile.tpl Dockerfile
sed -i 's/{{BITNAMI_IMAGE_VERSION}}/'"$BITNAMI_IMAGE_VERSION"'/g' Dockerfile
[[ ! -f bower.json ]] && sed -i '/^RUN bower install/d' Dockerfile
fi
if [[ ! -f .dockerignore ]]; then
@@ -92,10 +93,17 @@ add_dockerfile() {
fi
}
npm_install() {
if ! [[ -n $SKIP_NPM_INSTALL && $SKIP_NPM_INSTALL -gt 0 ]] && [[ -f package.json ]] && ! dependencies_up_to_date; then
log "Installing/Updating Express dependencies (npm)"
npm install
install_packages() {
if ! dependencies_up_to_date; then
if ! [[ -n $SKIP_NPM_INSTALL && $SKIP_NPM_INSTALL -gt 0 ]] && [[ -f package.json ]]; then
log "Installing npm packages"
npm install
fi
if ! [[ -n $SKIP_BOWER_INSTALL && $SKIP_BOWER_INSTALL -gt 0 ]] && [[ -f bower.json ]]; then
log "Installing bower packages"
bower install
fi
fi
}
@@ -122,7 +130,7 @@ if [ "$1" == npm ] && [ "$2" == "start" -o "$2" == "run" ]; then
add_dockerfile
npm_install
install_packages
if ! fresh_container; then
echo "#########################################################################"

View File

@@ -10,12 +10,14 @@ ENV NODE_ENV=production \
# Skip fetching dependencies and database migrations for production image
ENV SKIP_DB_WAIT=0 \
SKIP_DB_MIGRATION=1 \
SKIP_NPM_INSTALL=1
SKIP_NPM_INSTALL=1 \
SKIP_BOWER_INSTALL=1
COPY . /app
RUN sudo chown -R bitnami: /app
RUN npm install
RUN bower install
EXPOSE 3000
CMD ["npm", "start"]