Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions 18-minimal/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
24 changes: 22 additions & 2 deletions 18/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
24 changes: 22 additions & 2 deletions 20-minimal/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
24 changes: 22 additions & 2 deletions 20/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
3 changes: 3 additions & 0 deletions 22-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ Application developers can use the following environment variables to configure
**`NPM_TOKEN`**
Use authentication token for a custom NPM registry mirror

**`NPM_CI_STRICT`**
When set to "true", a failed `npm ci` (e.g. missing or out-of-sync `package-lock.json`) causes the build to fail immediately instead of falling back to `npm install` (default: "false")

One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.

Example: DATABASE_USER=sampleUser
Expand Down
24 changes: 22 additions & 2 deletions 22-minimal/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
3 changes: 3 additions & 0 deletions 22/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ Application developers can use the following environment variables to configure
**`NPM_TOKEN`**
Use authentication token for a custom NPM registry mirror

**`NPM_CI_STRICT`**
When set to "true", a failed `npm ci` (e.g. missing or out-of-sync `package-lock.json`) causes the build to fail immediately instead of falling back to `npm install` (default: "false")

One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.

Example: DATABASE_USER=sampleUser
Expand Down
24 changes: 22 additions & 2 deletions 22/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
3 changes: 3 additions & 0 deletions 24-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ Application developers can use the following environment variables to configure
**`NPM_TOKEN`**
Use authentication token for a custom NPM registry mirror

**`NPM_CI_STRICT`**
When set to "true", a failed `npm ci` (e.g. missing or out-of-sync `package-lock.json`) causes the build to fail immediately instead of falling back to `npm install` (default: "false")

One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.

Example: DATABASE_USER=sampleUser
Expand Down
24 changes: 22 additions & 2 deletions 24-minimal/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
3 changes: 3 additions & 0 deletions 24/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ Application developers can use the following environment variables to configure
**`NPM_TOKEN`**
Use authentication token for a custom NPM registry mirror

**`NPM_CI_STRICT`**
When set to "true", a failed `npm ci` (e.g. missing or out-of-sync `package-lock.json`) causes the build to fail immediately instead of falling back to `npm install` (default: "false")

One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.

Example: DATABASE_USER=sampleUser
Expand Down
24 changes: 22 additions & 2 deletions 24/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,32 @@ fi
if [ "$NODE_ENV" != "production" ]; then

echo "---> Building your Node application from source"
npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
npm install
fi

else

echo "---> Installing all dependencies"
NODE_ENV=development npm install

# Prefer npm ci for reproducible installs; fall back unless NPM_CI_STRICT=true
echo "---> Installing dependencies with npm ci"
if ! NODE_ENV=development npm ci; then
if [ "${NPM_CI_STRICT}" == "true" ]; then
echo "---> ERROR: npm ci failed and NPM_CI_STRICT=true; not falling back to npm install" >&2
exit 1
fi
echo "---> WARNING: npm ci failed, falling back to npm install (set NPM_CI_STRICT=true to disable this fallback)" >&2
NODE_ENV=development npm install
fi

#do not fail when there is no build script
echo "---> Building in production mode"
Expand Down
8 changes: 8 additions & 0 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ TEST_SET=${TESTS:-$TEST_LIST_NPM_TOKEN} ct_run_tests_from_testset "node_env_toke

cleanup

prepare app
check_prep_result $? app || exit
echo "Testing strict npm ci mode fails the build without a lockfile: s2i build -e NPM_CI_STRICT=true"
run_s2i_build "-e NPM_CI_STRICT=true"
evaluate_build_result $? "-should-fail-npm-ci-strict"

cleanup

run_s2i_build "-e NODE_ENV=development"
evaluate_build_result $? "-e NODE_ENV=development"

Expand Down