Skip to content

Commit a6a9271

Browse files
authored
Merge pull request docker-library#3 from polyverse/feature/add-alpine
Feature/add alpine
2 parents 551c2a8 + 5df518d commit a6a9271

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed

7.2/alpine3.8/fpm/Dockerfile

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
FROM golang
2+
WORKDIR /go/src/github.com/polyverse/
3+
COPY . .
4+
RUN git clone https://github.com/polyverse/php-scrambler.git
5+
WORKDIR ./php-scrambler
6+
RUN git checkout 8de1d48c2d410d1f3c4d02b9742dba164486c3fc
7+
RUN go get -v .
8+
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
9+
WORKDIR /go/src/github.com/polyverse/
10+
RUN git clone https://github.com/polyverse/tok-php-transformer.git
11+
WORKDIR ./tok-php-transformer
12+
RUN git checkout ff08cca989bd3c876955ce01f9692d7c1239af9d
13+
114
#
215
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
316
#
@@ -15,15 +28,20 @@ ENV PHPIZE_DEPS \
1528
g++ \
1629
gcc \
1730
libc-dev \
31+
vim \
1832
make \
1933
pkgconf \
2034
re2c
2135

2236
# persistent / runtime deps
2337
RUN apk add --no-cache --virtual .persistent-deps \
38+
$PHPIZE_DEPS \
2439
ca-certificates \
2540
curl \
2641
tar \
42+
bison \
43+
libxml2-dev \
44+
bash \
2745
xz \
2846
# https://github.com/docker-library/php/issues/494
2947
libressl
@@ -56,12 +74,11 @@ ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
5674

5775
ENV GPG_KEYS 1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F
5876

59-
ENV PHP_VERSION 7.2.13
77+
ENV PHP_VERSION 7.2.13-polyscripted
6078
ENV PHP_URL="https://secure.php.net/get/php-7.2.13.tar.xz/from/this/mirror" PHP_ASC_URL="https://secure.php.net/get/php-7.2.13.tar.xz.asc/from/this/mirror"
6179
ENV PHP_SHA256="14b0429abdb46b65c843e5882c9a8c46b31dfbf279c747293b8ab950c2644a4b" PHP_MD5=""
6280

6381
RUN set -xe; \
64-
\
6582
apk add --no-cache --virtual .fetch-deps \
6683
gnupg \
6784
wget \
@@ -93,6 +110,9 @@ RUN set -xe; \
93110
apk del .fetch-deps
94111

95112
COPY docker-php-source /usr/local/bin/
113+
COPY scripts/ /usr/local/bin/polyscripting
114+
ENV POLYSCRIPT_PATH "/usr/local/bin/polyscripting"
115+
ENV PHP_SRC_PATH "/usr/src/php"
96116

97117
RUN set -xe \
98118
&& apk add --no-cache --virtual .build-deps \
@@ -105,7 +125,6 @@ RUN set -xe \
105125
libsodium-dev \
106126
libxml2-dev \
107127
sqlite-dev \
108-
\
109128
&& export CFLAGS="$PHP_CFLAGS" \
110129
CPPFLAGS="$PHP_CPPFLAGS" \
111130
LDFLAGS="$PHP_LDFLAGS" \
@@ -138,22 +157,20 @@ RUN set -xe \
138157
--with-libedit \
139158
--with-openssl \
140159
--with-zlib \
160+
PHP_EXTRA_VERSION="-polyscripted" \
141161
\
142162
# bundled pcre does not support JIT on s390x
143163
# https://manpages.debian.org/stretch/libpcre3-dev/pcrejit.3.en.html#AVAILABILITY_OF_JIT_SUPPORT
144164
$(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \
145165
\
146166
$PHP_EXTRA_CONFIGURE_ARGS \
147-
&& make -j "$(nproc)" \
148-
&& make install \
167+
&& /usr/local/bin/polyscripting/polyscript-enable \
149168
&& { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \
150-
&& make clean \
151169
\
152170
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
153171
&& cp -v php.ini-* "$PHP_INI_DIR/" \
154172
\
155173
&& cd / \
156-
&& docker-php-source delete \
157174
\
158175
&& runDeps="$( \
159176
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
@@ -163,17 +180,17 @@ RUN set -xe \
163180
)" \
164181
&& apk add --no-cache --virtual .php-rundeps $runDeps \
165182
\
166-
&& apk del .build-deps \
167-
\
168183
# https://github.com/docker-library/php/issues/443
169184
&& pecl update-channels \
170185
&& rm -rf /tmp/pear ~/.pearrc
171186

187+
172188
COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
173189

174190
# sodium was built as a shared module (so that it can be replaced later if so desired), so let's enable it too (https://github.com/docker-library/php/issues/598)
175191
RUN docker-php-ext-enable sodium
176192

193+
177194
ENTRYPOINT ["docker-php-entrypoint"]
178195
##<autogenerated>##
179196
WORKDIR /var/www/html
@@ -214,6 +231,11 @@ RUN set -ex \
214231
echo 'listen = 9000'; \
215232
} | tee php-fpm.d/zz-docker.conf
216233

234+
WORKDIR /usr/local/bin/polyscripting
235+
COPY --from=0 /go/src/github.com/polyverse/php-scrambler/php-scrambler /usr/local/bin/polyscripting
236+
COPY --from=0 /go/src/github.com/polyverse/tok-php-transformer/tok-php-transformer.php /usr/local/bin/polyscripting
237+
COPY --from=0 /go/src/github.com/polyverse/tok-php-transformer/snip-transform.php /usr/local/bin/polyscripting
238+
217239
EXPOSE 9000
218240
CMD ["php-fpm"]
219241
##</autogenerated>##

7.2/alpine3.8/fpm/publish-image.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
image="polyverse/ps-php7.2-fpm"
4+
5+
echo "$(date) Obtaining current git sha for tagging the docker image"
6+
headsha=$(git rev-parse --verify HEAD)
7+
8+
9+
docker build -t $image:alpine-$headsha .
10+
docker push $image:alpine-$headsha
11+
12+
echo "Pushing as latest tag..."
13+
docker tag $image:alpine-$headsha $image:latest
14+
docker push $image:latest
15+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [ ! -f "$PATH/s_php" ]; then
4+
cp /usr/local/bin/php /usr/local/bin/s_php
5+
fi
6+
7+
./php-scrambler
8+
9+
cd $POLYSCRIPT_PATH
10+
s_php tok-php-transformer.php -p "$PHP_SRC_PATH"/ext/phar --replace --inc
11+
12+
cd $PHP_SRC_PATH
13+
make install -k
14+
15+
cd $POLYSCRIPT_PATH
16+
s_php tok-php-transformer.php -p "$PHP_SRC_PATH"/ext/phar/phar.php --replace
17+
18+
cd $PHP_SRC_PATH
19+
make install -k
20+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
sed -i '/^PHP_EXTRA_VERSION/s/"$/-poly"/' configure
4+
sed -i '/^PHP_EXTRA_VERSION/s/"$/-poly"/' configure.ac
5+
sed -i '/^PHP_EXTRA_VERSION/s"$/-poly"/' Makefile
6+
sed -i '/PHP_EXTRA_VERSION/s/""/"-poly"/' main/php_version.h
7+
sed -i '/PHP_VERSION "/s/"$/-poly"/' main/php_version.h
8+
9+
make -j "$(nproc)"
10+
make install
11+
make clean
12+
13+
cp "$POLYSCRIPT_PATH"/src/pharcommand.inc "$PHP_SRC_PATH"/ext/phar/phar/
14+
rm "$POLYSCRIPT_PATH"/polyscript-enable
15+

0 commit comments

Comments
 (0)