diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template
index 43e40974..d83935fe 100644
--- a/Dockerfile-alpine.template
+++ b/Dockerfile-alpine.template
@@ -127,8 +127,9 @@ RUN set -xe \
\
&& apk del .build-deps
-COPY docker-php-ext-* /usr/local/bin/
+COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
+ENTRYPOINT ["docker-php-entrypoint"]
####
CMD ["php", "-a"]
####
diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template
index 2f4de9cd..8634a845 100644
--- a/Dockerfile-debian.template
+++ b/Dockerfile-debian.template
@@ -117,8 +117,9 @@ RUN set -xe \
\
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps
-COPY docker-php-ext-* /usr/local/bin/
+COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
+ENTRYPOINT ["docker-php-entrypoint"]
####
CMD ["php", "-a"]
####
diff --git a/docker-php-entrypoint b/docker-php-entrypoint
new file mode 100755
index 00000000..88a016c1
--- /dev/null
+++ b/docker-php-entrypoint
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+ set -- php "$@"
+fi
+
+exec "$@"
diff --git a/update.sh b/update.sh
index 148649de..7b7276d4 100755
--- a/update.sh
+++ b/update.sh
@@ -106,14 +106,20 @@ for version in "${versions[@]}"; do
dockerfiles=()
{ generated_warning; cat Dockerfile-debian.template; } > "$version/Dockerfile"
- cp -v docker-php-ext-* "$version/"
- cp -v docker-php-source "$version/"
+ cp -v \
+ docker-php-entrypoint \
+ docker-php-ext-* \
+ docker-php-source \
+ "$version/"
dockerfiles+=( "$version/Dockerfile" )
if [ -d "$version/alpine" ]; then
{ generated_warning; cat Dockerfile-alpine.template; } > "$version/alpine/Dockerfile"
- cp -v docker-php-ext-* "$version/alpine/"
- cp -v docker-php-source "$version/alpine/"
+ cp -v \
+ docker-php-entrypoint \
+ docker-php-ext-* \
+ docker-php-source \
+ "$version/alpine/"
dockerfiles+=( "$version/alpine/Dockerfile" )
fi
@@ -138,8 +144,11 @@ for version in "${versions[@]}"; do
ia { ac++ }
ia && ac == 1 { system("cat '$variant'-Dockerfile-block-" ab) }
' "$base" > "$version/$target/Dockerfile"
- cp -v docker-php-ext-* "$version/$target/"
- cp -v docker-php-source "$version/$target/"
+ cp -v \
+ docker-php-entrypoint \
+ docker-php-ext-* \
+ docker-php-source \
+ "$version/$target/"
dockerfiles+=( "$version/$target/Dockerfile" )
done
@@ -155,6 +164,13 @@ for version in "${versions[@]}"; do
"${dockerfiles[@]}"
)
+ # update entrypoint commands
+ for dockerfile in "${dockerfiles[@]}"; do
+ cmd="$(awk '$1 == "CMD" { $1 = ""; print }' "$dockerfile" | tail -1 | jq --raw-output '.[0]')"
+ entrypoint="$(dirname "$dockerfile")/docker-php-entrypoint"
+ sed -i 's! php ! '"$cmd"' !g' "$entrypoint"
+ done
+
newTravisEnv=
for dockerfile in "${dockerfiles[@]}"; do
dir="${dockerfile%Dockerfile}"