Skip to content

Remove extracted php src #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \
re2c
RUN apk add --no-cache --virtual .persistent-deps \
ca-certificates \
curl
curl \
tar \
xz

# ensure www-data user exists
RUN set -x \
Expand All @@ -35,28 +37,33 @@ ENV PHP_VERSION %%PHP_VERSION%%
ENV PHP_FILENAME %%PHP_FILENAME%%
ENV PHP_SHA256 %%PHP_SHA256%%

RUN set -xe \
&& apk add --no-cache --virtual .fetch-deps \
gnupg \
&& mkdir -p /usr/src \
&& cd /usr/src/ \
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o php.tar.xz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

&& echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c - \
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o php.tar.xz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done \
&& gpg --batch --verify php.tar.xz.asc php.tar.xz \
&& rm -r "$GNUPGHOME" \
&& apk del .fetch-deps

COPY docker-php-source /usr/local/bin/

RUN set -xe \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
curl-dev \
gnupg \
libedit-dev \
libxml2-dev \
openssl-dev \
sqlite-dev \
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \
&& echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done \
&& gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \
&& rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \
&& mkdir -p /usr/src \
&& tar -Jxf "$PHP_FILENAME" -C /usr/src \
&& mv "/usr/src/php-$PHP_VERSION" /usr/src/php \
&& rm "$PHP_FILENAME" \
&& docker-php-source extract \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path="$PHP_INI_DIR" \
Expand All @@ -83,7 +90,8 @@ RUN set -xe \
| sort -u \
)" \
&& apk add --no-cache --virtual .php-rundeps $runDeps \
&& apk del .build-deps
&& apk del .build-deps \
&& docker-php-source delete

COPY docker-php-ext-* /usr/local/bin/

Expand Down
32 changes: 18 additions & 14 deletions Dockerfile-debian.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \
libedit2 \
libsqlite3-0 \
libxml2 \
xz-utils \
--no-install-recommends && rm -r /var/lib/apt/lists/*

ENV PHP_INI_DIR /usr/local/etc/php
Expand All @@ -31,6 +32,20 @@ ENV PHP_VERSION %%PHP_VERSION%%
ENV PHP_FILENAME %%PHP_FILENAME%%
ENV PHP_SHA256 %%PHP_SHA256%%

RUN set -xe \
&& cd /usr/src/ \
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o php.tar.xz \
&& echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c - \
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o php.tar.xz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done \
&& gpg --batch --verify php.tar.xz.asc php.tar.xz \
&& rm -r "$GNUPGHOME"

COPY docker-php-source /usr/local/bin/

RUN set -xe \
&& buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
Expand All @@ -39,21 +54,9 @@ RUN set -xe \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
xz-utils \
" \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \
&& echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done \
&& gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \
&& rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \
&& mkdir -p /usr/src/php \
&& tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \
&& rm "$PHP_FILENAME" \
&& docker-php-source extract \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path="$PHP_INI_DIR" \
Expand All @@ -72,7 +75,8 @@ RUN set -xe \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& make clean \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \
&& docker-php-source delete

COPY docker-php-ext-* /usr/local/bin/

Expand Down
9 changes: 5 additions & 4 deletions docker-php-ext-configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
set -e

ext="$1"
extDir="/usr/src/php/ext/$ext"
if [ -z "$ext" ] || ! [ -d "$extDir" ]; then
if [ -z "$ext" ] || ! grep -qE "^$ext$" /usr/src/php-available-exts; then
echo >&2 "usage: $0 ext-name [configure flags]"
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
echo >&2
echo >&2 'Possible values for ext-name:'
echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
echo $(cat /usr/src/php-available-exts)
exit 1
fi
shift
Expand All @@ -28,7 +27,9 @@ if [ "$pm" = 'apk' ]; then
fi
fi

docker-php-source extract

set -x
cd "$extDir"
cd "/usr/src/php/ext/$ext"
phpize
./configure "$@"
12 changes: 7 additions & 5 deletions docker-php-ext-install
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh
set -e

cd /usr/src/php/ext

usage() {
echo "usage: $0 [-jN] ext-name [ext-name ...]"
echo " ie: $0 gd mysqli"
Expand All @@ -12,7 +10,7 @@ usage() {
echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
echo
echo 'Possible values for ext-name:'
echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
echo $(cat /usr/src/php-available-exts)
}

opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
Expand Down Expand Up @@ -41,8 +39,8 @@ for ext; do
if [ -z "$ext" ]; then
continue
fi
if [ ! -d "$ext" ]; then
echo >&2 "error: $(pwd -P)/$ext does not exist"
if ! grep -qE "^$ext$" /usr/src/php-available-exts; then
echo >&2 "error: /usr/src/php/ext/$ext does not exist"
echo >&2
usage >&2
exit 1
Expand Down Expand Up @@ -72,6 +70,9 @@ if [ "$pm" = 'apk' ]; then
fi
fi

docker-php-source extract
cd /usr/src/php/ext

for ext in $exts; do
(
cd "$ext"
Expand All @@ -90,3 +91,4 @@ done
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
apk del $apkDel
fi
docker-php-source delete
44 changes: 44 additions & 0 deletions docker-php-source
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
set -e
dir=/usr/src/php

usage() {
echo "usage: $0 COMMAND"
echo
echo "Manage php source tarball lifecycle."
echo
echo "Commands:"
echo " extract extract php source tarball into directory $dir if not already done."
echo " delete delete extracted php source located into $dir if not already done."
echo
}

case "$1" in
extract)
if [ -e "$dir" -a ! -d "$dir" ] ; then
echo >&2 "$dir exists and is not a directory"
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you should use the same exit code than when an unsupported command (≠extract,delete) is passed.

fi
if [ ! -d "$dir" ]; then
mkdir -p "$dir"
tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1

if [ ! -f /usr/src/php-available-exts ]; then
find "$dir/ext" \
-mindepth 2 \
-maxdepth 2 \
-type f \
-name 'config.m4' \
| xargs -n1 dirname | xargs -n1 basename | sort \
> /usr/src/php-available-exts
fi
fi
;;
delete)
rm -rf "$dir"
;;
*)
usage
exit 1
;;
esac
3 changes: 3 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ for version in "${versions[@]}"; do

cp -v Dockerfile-debian.template "$version/Dockerfile"
cp -v docker-php-ext-* "$version/"
cp -v docker-php-source "$version/"
dockerfiles+=( "$version/Dockerfile" )

if [ -d "$version/alpine" ]; then
cp -v Dockerfile-alpine.template "$version/alpine/Dockerfile"
cp -v docker-php-ext-* "$version/alpine/"
cp -v docker-php-source "$version/alpine/"
dockerfiles+=( "$version/alpine/Dockerfile" )
fi

Expand All @@ -98,6 +100,7 @@ for version in "${versions[@]}"; do
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/"
dockerfiles+=( "$version/$target/Dockerfile" )
done

Expand Down