Add simple initial entrypoint for supporting "docker run php --flags"

This commit is contained in:
Tianon Gravi 2016-12-10 09:20:49 -08:00
parent 35080ccd4c
commit 703ba52e0c
4 changed files with 35 additions and 8 deletions

View File

@ -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"]
##<autogenerated>##
CMD ["php", "-a"]
##</autogenerated>##

View File

@ -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"]
##<autogenerated>##
CMD ["php", "-a"]
##</autogenerated>##

9
docker-php-entrypoint Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php "$@"
fi
exec "$@"

View File

@ -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}"