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

View File

@ -117,8 +117,9 @@ RUN set -xe \
\ \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps && 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>## ##<autogenerated>##
CMD ["php", "-a"] CMD ["php", "-a"]
##</autogenerated>## ##</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=() dockerfiles=()
{ generated_warning; cat Dockerfile-debian.template; } > "$version/Dockerfile" { generated_warning; cat Dockerfile-debian.template; } > "$version/Dockerfile"
cp -v docker-php-ext-* "$version/" cp -v \
cp -v docker-php-source "$version/" docker-php-entrypoint \
docker-php-ext-* \
docker-php-source \
"$version/"
dockerfiles+=( "$version/Dockerfile" ) dockerfiles+=( "$version/Dockerfile" )
if [ -d "$version/alpine" ]; then if [ -d "$version/alpine" ]; then
{ generated_warning; cat Dockerfile-alpine.template; } > "$version/alpine/Dockerfile" { generated_warning; cat Dockerfile-alpine.template; } > "$version/alpine/Dockerfile"
cp -v docker-php-ext-* "$version/alpine/" cp -v \
cp -v docker-php-source "$version/alpine/" docker-php-entrypoint \
docker-php-ext-* \
docker-php-source \
"$version/alpine/"
dockerfiles+=( "$version/alpine/Dockerfile" ) dockerfiles+=( "$version/alpine/Dockerfile" )
fi fi
@ -138,8 +144,11 @@ for version in "${versions[@]}"; do
ia { ac++ } ia { ac++ }
ia && ac == 1 { system("cat '$variant'-Dockerfile-block-" ab) } ia && ac == 1 { system("cat '$variant'-Dockerfile-block-" ab) }
' "$base" > "$version/$target/Dockerfile" ' "$base" > "$version/$target/Dockerfile"
cp -v docker-php-ext-* "$version/$target/" cp -v \
cp -v docker-php-source "$version/$target/" docker-php-entrypoint \
docker-php-ext-* \
docker-php-source \
"$version/$target/"
dockerfiles+=( "$version/$target/Dockerfile" ) dockerfiles+=( "$version/$target/Dockerfile" )
done done
@ -155,6 +164,13 @@ for version in "${versions[@]}"; do
"${dockerfiles[@]}" "${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= newTravisEnv=
for dockerfile in "${dockerfiles[@]}"; do for dockerfile in "${dockerfiles[@]}"; do
dir="${dockerfile%Dockerfile}" dir="${dockerfile%Dockerfile}"