Docker Entrypoint Script To Support One or Two or Both Commands (namely npm config & npm run)
Here's a tentative quick hack to allow you to pass in configuration parameters with -v
options.
#!/bin/shset -e# Quick and dirty option processingwhile [ $1 = '-v' ]; do case $2 in *=*) option=${2%=*} npm config set "$option" "${2#$option}" shift 2;; *) echo "$0: Fatal error: argument to -v must contain =" >&2 exit 127;; esacdone# Aside; use = not == inside [ ... ] if [ "$1" = 'npm' ] && [ "$2" = 'run' ]; then shift 2 XVFB_SCREEN_WIDTH=${SCREEN_WIDTH-1280} XVFB_SCREEN_HEIGHT=${SCREEN_HEIGHT-720} dbus-daemon --session --fork Xvfb :1 -screen 0 "${XVFB_SCREEN_WIDTH}x${XVFB_SCREEN_HEIGHT}x24" >/dev/null 2>&1 & export DISPLAY=:1.0 fluxbox >/dev/null 2>&1 & exec npm run "$@"fiexec "$@"
Usage:
docker run --rm -it \ -v $PWD/e2e/:/opt/SYSTAC/e2e \ -v $PWD/reports/:/opt/SYSTAC/reports/ \ bhreinb/SYSTAC \ scriptname -v foo=bar \ -v packageJson:task-profile=auto-regression-chrome \ -v baz=quux \ npm run gargleblaster --demo --crash --splinters