From d1138cb5a5b0b6005894c345b016850f71c8ffe5 Mon Sep 17 00:00:00 2001 From: runzexia Date: Sun, 17 Mar 2019 15:48:24 +0800 Subject: [PATCH] add yarn support --- 10/Dockerfile | 2 ++ 10/s2i/bin/assemble | 57 ++++++++++++++++++++++++--------------------- 4/Dockerfile | 2 ++ 4/s2i/bin/assemble | 54 +++++++++++++++++++++++------------------- 6/Dockerfile | 2 ++ 6/s2i/bin/assemble | 54 +++++++++++++++++++++++------------------- 8/Dockerfile | 2 ++ 8/s2i/bin/assemble | 57 ++++++++++++++++++++++++--------------------- 8 files changed, 130 insertions(+), 100 deletions(-) diff --git a/10/Dockerfile b/10/Dockerfile index 1455f29..c513e6a 100644 --- a/10/Dockerfile +++ b/10/Dockerfile @@ -56,6 +56,8 @@ RUN yum install -y centos-release-scl-rh && \ rpm -V $INSTALL_PKGS && \ yum clean all -y +RUN npm install -g yarn -s &>/dev/null && yum clean all -y + # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/10/s2i/bin/assemble b/10/s2i/bin/assemble index 33b9fc3..5f7010e 100755 --- a/10/s2i/bin/assemble +++ b/10/s2i/bin/assemble @@ -70,36 +70,41 @@ if [ -z "$NODE_ENV" ]; then fi fi -if [ "$NODE_ENV" != "production" ]; then +if [ ! -z "$YARN_ENABLED" ]; then + echo "---> Using 'yarn install' with YARN_ARGS" + yarn install $YARN_ARGS +else + if [ "$NODE_ENV" != "production" ]; then - echo "---> Building your Node application from source" - npm install + echo "---> Building your Node application from source" + npm install -else + else - echo "---> Installing all dependencies" - NODE_ENV=development npm install - - #do not fail when there is no build script - echo "---> Building in production mode" - npm run build --if-present - - echo "---> Pruning the development dependencies" - npm prune - - # Clear the npm's cache and tmp directories only if they are not a docker volumes - NPM_CACHE=$(npm config get cache) - if ! mountpoint $NPM_CACHE; then - echo "---> Cleaning the npm cache $NPM_CACHE" - #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory - rm $NPM_CACHE* -rf - fi - NPM_TMP=$(npm config get tmp) - if ! mountpoint $NPM_TMP; then - echo "---> Cleaning the $NPM_TMP/npm-*" - rm -rf $NPM_TMP/npm-* - fi + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run build --if-present + + echo "---> Pruning the development dependencies" + npm prune + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + rm $NPM_CACHE* -rf + fi + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + fi fi # Fix source directory permissions diff --git a/4/Dockerfile b/4/Dockerfile index 2de1e1e..f9f7e8c 100644 --- a/4/Dockerfile +++ b/4/Dockerfile @@ -57,6 +57,8 @@ RUN yum install -y centos-release-scl-rh && \ rpm -V $INSTALL_PKGS && \ yum clean all -y +RUN npm install -g yarn -s &>/dev/null && yum clean all -y + # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/4/s2i/bin/assemble b/4/s2i/bin/assemble index db30103..8afaeb8 100755 --- a/4/s2i/bin/assemble +++ b/4/s2i/bin/assemble @@ -70,35 +70,41 @@ if [ -z "$NODE_ENV" ]; then fi fi -if [ "$NODE_ENV" != "production" ]; then - - echo "---> Building your Node application from source" - npm install - +if [ ! -z "$YARN_ENABLED" ]; then + echo "---> Using 'yarn install' with YARN_ARGS" + yarn install $YARN_ARGS else + if [ "$NODE_ENV" != "production" ]; then - echo "---> Installing all dependencies" - NODE_ENV=development npm install - - #do not fail when there is no build script - echo "---> Building in production mode" - npm run build --if-present + echo "---> Building your Node application from source" + npm install - echo "---> Pruning the development dependencies" - npm prune + else - # Clear the npm's cache and tmp directories only if they are not a docker volumes - NPM_CACHE=$(npm config get cache) - if ! mountpoint $NPM_CACHE; then - echo "---> Cleaning the npm cache $NPM_CACHE" - npm cache clean - fi - NPM_TMP=$(npm config get tmp) - if ! mountpoint $NPM_TMP; then - echo "---> Cleaning the $NPM_TMP/npm-*" - rm -rf $NPM_TMP/npm-* - fi + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run build --if-present + + echo "---> Pruning the development dependencies" + npm prune + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + rm $NPM_CACHE* -rf + fi + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + fi fi # Fix source directory permissions diff --git a/6/Dockerfile b/6/Dockerfile index b9f412b..3797331 100644 --- a/6/Dockerfile +++ b/6/Dockerfile @@ -56,6 +56,8 @@ RUN yum install -y centos-release-scl-rh && \ rpm -V $INSTALL_PKGS && \ yum clean all -y +RUN npm install -g yarn -s &>/dev/null && yum clean all -y + # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/6/s2i/bin/assemble b/6/s2i/bin/assemble index 055d313..fcbad10 100755 --- a/6/s2i/bin/assemble +++ b/6/s2i/bin/assemble @@ -70,35 +70,41 @@ if [ -z "$NODE_ENV" ]; then fi fi -if [ "$NODE_ENV" != "production" ]; then - - echo "---> Building your Node application from source" - npm install - +if [ ! -z "$YARN_ENABLED" ]; then + echo "---> Using 'yarn install' with YARN_ARGS" + yarn install $YARN_ARGS else + if [ "$NODE_ENV" != "production" ]; then - echo "---> Installing all dependencies" - NODE_ENV=development npm install - - #do not fail when there is no build script - echo "---> Building in production mode" - npm run build --if-present + echo "---> Building your Node application from source" + npm install - echo "---> Pruning the development dependencies" - npm prune + else - # Clear the npm's cache and tmp directories only if they are not a docker volumes - NPM_CACHE=$(npm config get cache) - if ! mountpoint $NPM_CACHE; then - echo "---> Cleaning the npm cache $NPM_CACHE" - npm cache clean - fi - NPM_TMP=$(npm config get tmp) - if ! mountpoint $NPM_TMP; then - echo "---> Cleaning the $NPM_TMP/npm-*" - rm -rf $NPM_TMP/npm-* - fi + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run build --if-present + + echo "---> Pruning the development dependencies" + npm prune + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + rm $NPM_CACHE* -rf + fi + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + fi fi # Fix source directory permissions diff --git a/8/Dockerfile b/8/Dockerfile index ae3075c..49513c5 100644 --- a/8/Dockerfile +++ b/8/Dockerfile @@ -56,6 +56,8 @@ RUN yum install -y centos-release-scl-rh && \ rpm -V $INSTALL_PKGS && \ yum clean all -y +RUN npm install -g yarn -s &>/dev/null && yum clean all -y + # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH diff --git a/8/s2i/bin/assemble b/8/s2i/bin/assemble index 33b9fc3..5f7010e 100755 --- a/8/s2i/bin/assemble +++ b/8/s2i/bin/assemble @@ -70,36 +70,41 @@ if [ -z "$NODE_ENV" ]; then fi fi -if [ "$NODE_ENV" != "production" ]; then +if [ ! -z "$YARN_ENABLED" ]; then + echo "---> Using 'yarn install' with YARN_ARGS" + yarn install $YARN_ARGS +else + if [ "$NODE_ENV" != "production" ]; then - echo "---> Building your Node application from source" - npm install + echo "---> Building your Node application from source" + npm install -else + else - echo "---> Installing all dependencies" - NODE_ENV=development npm install - - #do not fail when there is no build script - echo "---> Building in production mode" - npm run build --if-present - - echo "---> Pruning the development dependencies" - npm prune - - # Clear the npm's cache and tmp directories only if they are not a docker volumes - NPM_CACHE=$(npm config get cache) - if ! mountpoint $NPM_CACHE; then - echo "---> Cleaning the npm cache $NPM_CACHE" - #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory - rm $NPM_CACHE* -rf - fi - NPM_TMP=$(npm config get tmp) - if ! mountpoint $NPM_TMP; then - echo "---> Cleaning the $NPM_TMP/npm-*" - rm -rf $NPM_TMP/npm-* - fi + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run build --if-present + + echo "---> Pruning the development dependencies" + npm prune + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + rm $NPM_CACHE* -rf + fi + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + fi fi # Fix source directory permissions