From 42bf4d02644a14868f7518817fea7e09795fbdd7 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Tue, 16 Jan 2018 18:25:31 +0100 Subject: [PATCH] try to fix dockerhub build --- images/manager-app/Dockerfile | 11 +++--- images/manager-app/assemble.sh | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100755 images/manager-app/assemble.sh diff --git a/images/manager-app/Dockerfile b/images/manager-app/Dockerfile index 3885aaf..e9ce825 100644 --- a/images/manager-app/Dockerfile +++ b/images/manager-app/Dockerfile @@ -12,13 +12,14 @@ USER root RUN tar -xf $APP_ROOT/etc/$OC_TOOL.tar.gz -C $APP_ROOT/etc && \ mv $APP_ROOT/etc/$OC_TOOL $APP_ROOT/etc/oc-tool && \ - git clone https://github.com/ruromero/devconf /tmp/src/devconf && \ - cp -r /tmp/src/devconf/manager-app/. /tmp/src/ && \ - rm -rf /tmp/src/devconf && \ - chown -R 1001 /tmp/src + git clone https://github.com/ruromero/devconf devconf && \ + chown 1001 -R devconf && \ + cp -r devconf/manager-app/. . && \ + rm -rf devconf USER 1001 -RUN $STI_SCRIPTS_PATH/assemble +ADD assemble.sh $HOME/ +RUN $HOME/assemble.sh CMD $STI_SCRIPTS_PATH/run diff --git a/images/manager-app/assemble.sh b/images/manager-app/assemble.sh new file mode 100755 index 0000000..2cbdb05 --- /dev/null +++ b/images/manager-app/assemble.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Prevent running assemble in builders different than official STI image. +# The official nodejs:6-onbuild already run npm install and use different +# application folder. +[ -d "/usr/src/app" ] && exit 0 + +set -e + +# FIXME: Linking of global modules is disabled for now as it causes npm failures +# under RHEL7 +# Global modules good to have +# npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u) +# Available global modules; only match top-level npm packages +#global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u) +# List all modules in common +#module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ') +# Link the modules +#npm link $module_list + +safeLogging () { + if [[ $1 =~ http[s]?://.*@.*$ ]]; then + echo $1 | sed 's/^.*@/redacted@/' + else + echo $1 + fi +} + +shopt -s dotglob +echo "---> Installing application source ..." + +if [ ! -z $HTTP_PROXY ]; then + echo "---> Setting npm http proxy to" $(safeLogging $HTTP_PROXY) + npm config set proxy $HTTP_PROXY +fi + +if [ ! -z $http_proxy ]; then + echo "---> Setting npm http proxy to" $(safeLogging $http_proxy) + npm config set proxy $http_proxy +fi + +if [ ! -z $HTTPS_PROXY ]; then + echo "---> Setting npm https proxy to" $(safeLogging $HTTPS_PROXY) + npm config set https-proxy $HTTPS_PROXY +fi + +if [ ! -z $https_proxy ]; then + echo "---> Setting npm https proxy to" $(safeLogging $https_proxy) + npm config set https-proxy $https_proxy +fi + +# Change the npm registry mirror if provided +if [ -n "$NPM_MIRROR" ]; then + npm config set registry $NPM_MIRROR +fi + +echo "---> Building your Node application from source" +npm install + +# Fix source directory permissions +fix-permissions ./