Skip to content

Commit

Permalink
add yarn support
Browse files Browse the repository at this point in the history
  • Loading branch information
runzexia committed Mar 17, 2019
1 parent 6d2e46d commit d1138cb
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 100 deletions.
2 changes: 2 additions & 0 deletions 10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
57 changes: 31 additions & 26 deletions 10/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 30 additions & 24 deletions 4/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 30 additions & 24 deletions 6/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
57 changes: 31 additions & 26 deletions 8/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d1138cb

Please sign in to comment.