Skip to content

Commit e29935e

Browse files
committed
Fix docker-entrypoint.sh file handling, closes #1456
The docker-entrypoint.sh script added in #1039 is intended to run the supplied command with "node" if it contains a "-" or doesn't correspond to a system command. In Alpine, this doesn't work if the supplied command corresponds to a regular, non-executable JS file. The root issue is a bug in ash/dash: its implementation of "command -v" incorrectly outputs the supplied command_name even for non-executable files. This is a violation of the POSIX standard and has been reported to the Debian team in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264, though there's been no activity in several years. As a workaround, this adds an additional check to docker-entrypoint.sh for regular files that aren't marked as executable.
1 parent 6149e33 commit e29935e

31 files changed

+124
-31
lines changed

12/alpine3.11/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/alpine3.12/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/alpine3.13/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/alpine3.14/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/bullseye-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/bullseye/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/buster-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/buster/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/stretch-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

12/stretch/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/alpine3.11/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/alpine3.12/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/alpine3.13/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/alpine3.14/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/bullseye-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/bullseye/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/buster-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/buster/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/stretch-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

14/stretch/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/alpine3.11/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/alpine3.12/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/alpine3.13/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/alpine3.14/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/bullseye-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/bullseye/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/buster-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/buster/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/stretch-slim/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

16/stretch/docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

docker-entrypoint.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
4+
# Run command with node if the first argument contains a "-" or is not a system command. The last
5+
# part inside the "{}" is a workaround for the following bug in ash/dash:
6+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
7+
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
58
set -- node "$@"
69
fi
710

0 commit comments

Comments
 (0)