Skip to content

Commit 23ff933

Browse files
authored
Merge pull request docker-library#7 from polyverse/add-polyscripting
Add polyscripting dependencies
2 parents 89bae46 + 030beff commit 23ff933

28 files changed

+865
-43
lines changed

.DS_Store

-6 KB
Binary file not shown.

7.2/.DS_Store

-6 KB
Binary file not shown.

7.2/alpine3.11/fpm/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM polyverse/polyscript-deps:29fc2e4b99953abeb3f5653481d19c818684d393
1+
FROM polyverse/php-polyscripting-builder:latest as builder
22

33
#
44
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
@@ -105,13 +105,11 @@ RUN set -eux; \
105105

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

108-
#POLYSCRIPTING ADDED
108+
#add polyscripting
109109
ENV POLYSCRIPT_PATH "/usr/local/bin/polyscripting"
110110
ENV PHP_SRC_PATH "/usr/src/php"
111111
WORKDIR $POLYSCRIPT_PATH
112-
COPY --from=0 /tok-php-transformer/tok-php-transformer.php /tok-php-transformer/snip-transform.php ./
113-
COPY --from=0 /scripts/ .
114-
COPY --from=0 /apache/ .
112+
COPY --from=builder /polyscripting/ ./
115113

116114
RUN set -eux; \
117115
apk add --no-cache --virtual .build-deps \
@@ -169,7 +167,7 @@ RUN set -eux; \
169167
\
170168
${PHP_EXTRA_CONFIGURE_ARGS:-} \
171169
; \
172-
/usr/local/bin/polyscripting/polyscript-enable; \
170+
${POLYSCRIPT_PATH}/polyscript-enable; \
173171
find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; \
174172
\
175173
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
@@ -244,4 +242,4 @@ STOPSIGNAL SIGQUIT
244242

245243
EXPOSE 9000
246244
CMD ["php-fpm"]
247-
##</autogenerated>##
245+
##</autogenerated>##

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
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+
echo "Building image $image:$headsha"
9+
docker build -t $image:$headsha .
10+
11+
if [[ "$1" == "-p" ]]; then
12+
echo "Pushing as latest tag..."
13+
docker tag $image:$headsha $image:latest
14+
docker push $image:latest
15+
fi

7.2/alpine3.9/.DS_Store

-6 KB
Binary file not shown.

7.2/stretch/apache/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM polyverse/polyscript-deps:29fc2e4b99953abeb3f5653481d19c818684d393
1+
FROM polyverse/php-polyscripting-builder:latest as builder
22

33
FROM debian:stretch-slim
44

@@ -163,13 +163,13 @@ RUN set -eux; \
163163

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

166-
#POLYSCRIPTING ADDED
166+
#add polyscripting
167167
ENV POLYSCRIPT_PATH "/usr/local/bin/polyscripting"
168168
ENV PHP_SRC_PATH "/usr/src/php"
169169
WORKDIR $POLYSCRIPT_PATH
170-
COPY --from=0 /tok-php-transformer/tok-php-transformer.php /tok-php-transformer/snip-transform.php ./
171-
COPY --from=0 /scripts/ .
172-
COPY --from=0 /apache/ .
170+
COPY --from=builder /polyscripting/ ./
171+
172+
173173

174174
RUN set -eux; \
175175
\
@@ -251,7 +251,7 @@ RUN set -eux; \
251251
\
252252
${PHP_EXTRA_CONFIGURE_ARGS:-} \
253253
; \
254-
$POLYSCRIPT_PATH/polyscript-enable; \
254+
${POLYSCRIPT_PATH}/polyscript-enable; \
255255
find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \
256256
\
257257
# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
@@ -292,4 +292,4 @@ WORKDIR /var/www/html
292292

293293
EXPOSE 80
294294
CMD ["apache2-foreground"]
295-
##</autogenerated>##
295+
##</autogenerated>##

7.2/stretch/apache/publish-image.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
image="polyverse/ps-php7.2-apache"
44

55
echo "$(date) Obtaining current git sha for tagging the docker image"
66
headsha=$(git rev-parse --verify HEAD)
77

8-
8+
echo "Building image $image:$headsha"
99
docker build -t $image:$headsha .
1010

1111
if [[ "$1" == "-p" ]]; then
12-
docker push $image:$headsha
1312
echo "Pushing as latest tag..."
1413
docker tag $image:$headsha $image:latest
1514
docker push $image:latest

7.4/alpine3.10/cli/publish-image.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

7.4/alpine3.11/fpm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,4 @@ STOPSIGNAL SIGQUIT
240240

241241
EXPOSE 9000
242242
CMD ["php-fpm"]
243-
##</autogenerated>##
243+
##</autogenerated>##

7.4/buster/apache/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
FROM polyverse/php-polyscripting-builder:latest as builder
12
#
23
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
34
#
45
# PLEASE DO NOT EDIT IT DIRECTLY.
56
#
6-
FROM polyverse/polyscript-deps:29fc2e4b99953abeb3f5653481d19c818684d393 AS polyscript-deps
77

88
FROM debian:buster-slim
99

@@ -168,13 +168,13 @@ RUN set -eux; \
168168

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

171-
#POLYSCRIPTING ADDED
171+
#add polyscripting
172172
ENV POLYSCRIPT_PATH "/usr/local/bin/polyscripting"
173173
ENV PHP_SRC_PATH "/usr/src/php"
174174
WORKDIR $POLYSCRIPT_PATH
175-
COPY --from=polyscript-deps /tok-php-transformer/tok-php-transformer.php /tok-php-transformer/snip-transform.php ./
176-
COPY --from=polyscript-deps /scripts/ .
177-
COPY --from=polyscript-deps /apache/ .
175+
COPY --from=builder /polyscripting/ ./
176+
177+
178178

179179
RUN set -eux; \
180180
\

polyscripting/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang
2+
3+
COPY src/tokenizer /polyscripting/
4+
COPY scripts /polyscripting/
5+
6+
COPY ./src/scrambler/* /go/src/github.com/polyverse/scrambler/
7+
8+
WORKDIR /go/src/github.com/polyverse/scrambler
9+
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /polyscripting/php-scrambler
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/sh
22

3-
image="polyverse/ps-php7.2-fpm"
3+
image="polyverse/php-polyscripting-builder"
44

55
echo "$(date) Obtaining current git sha for tagging the docker image"
66
headsha=$(git rev-parse --verify HEAD)
77

8-
98
docker build -t $image:$headsha .
9+
docker tag $image:$headsha $image:latest
10+
1011

1112
if [[ "$1" == "-p" ]]; then
1213
docker push $image:$headsha
13-
echo "Pushing as latest tag..."
1414
docker tag $image:$headsha $image:latest
15-
docker push $image:latest
16-
fi
15+
docker push $image:latest
16+
fi
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
copy_dependencies() {
4+
cp -n $PHP_EXEC/php $PHP_EXEC/s_php
5+
cp -n $PHP_EXEC/s_php $POLYSCRIPT_PATH
6+
cp -n $PHP_SRC_PATH/ext/phar/phar.php $POLYSCRIPT_PATH
7+
cp -n $PHP_SRC_PATH/Zend/zend_language_scanner.l $POLYSCRIPT_PATH
8+
cp -n $PHP_SRC_PATH/Zend/zend_language_parser.y $POLYSCRIPT_PATH
9+
10+
11+
}
12+
13+
reset_php() {
14+
cp $POLYSCRIPT_PATH/phar.php $PHP_SRC_PATH/ext/phar/phar.php
15+
rm -f $PHP_SRC_PATH/Zend/zend_language_scanner.c
16+
rm -f $PHP_SRC_PATH/Zend/zend_language_parser.c
17+
}
18+
19+
transform_lambda() {
20+
/runtime/bin/php tok-php-transformer.php -p /runtime --replace
21+
/runtime/bin/php tok-php-transformer.php -s "$(cat /runtime/bootstrap)" > /runtime/bootstrap
22+
}
23+
24+
copy_dependencies
25+
26+
if [[ "$MODE" == "polyscripted" || -f $POLYSCRIPT_PATH ]]; then
27+
28+
echo "===================== POLYSCRIPTING ENABLED =========================="
29+
echo "Setting up Polyscripting...."
30+
reset_php
31+
echo "Scrambling php source."
32+
./php-scrambler
33+
34+
echo "Recompiling polyscripted PHP..."
35+
$PHP_EXEC/s_php tok-php-transformer.php -p $PHP_SRC_PATH/ext/phar/phar.php --replace
36+
37+
cd $PHP_SRC_PATH;
38+
make -o ext/phar/phar.php install;
39+
40+
cd $POLYSCRIPT_PATH;
41+
42+
echo "Transforming lambda files..."
43+
transform_lambda
44+
$PHP_EXEC/s_php tok-php-transformer.php -p ./phar.php --replace
45+
else
46+
echo "===================== POLYSCRIPTING DISABLED =========================="
47+
echo "To enable polyscripting set MODE = 'polyscripted'"
48+
fi
49+
reset_php

polyscripting/run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
image="polyverse/php-polyscripting-builder"
4+
headsha=$(git rev-parse --verify HEAD)
5+
6+
7+
docker run -it $image:$headsha bash
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ ! -v PHP_EXEC ]; then
4+
PHP_EXEC=/usr/local/bin
5+
fi
6+
7+
if [ ! -f "${PHP_EXEC}/s_php" ]; then
8+
cp $PHP_EXEC/php $PHP_EXEC/s_php
9+
fi
10+
11+
12+
./php-scrambler
13+
14+
cp $PHP_SRC_PATH/ext/phar/phar.php .
15+
16+
$PHP_EXEC/s_php tok-php-transformer.php -p ./phar.php --replace
17+
mv ./phar.php $PHP_SRC_PATH/ext/phar/phar.php
18+
19+
cd $PHP_SRC_PATH; make -o ext/phar/phar.php install -k; cd $POLYSCRIPT_PATH;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
sed -i '/^PHP_EXTRA_VERSION/s/"$/-poly"/' configure configure.ac Makefile
4+
sed -i '/PHP_EXTRA_VERSION/s/""/"-poly"/' main/php_version.h
5+
sed -i '/PHP_VERSION "/s/"$/-poly"/' main/php_version.h
6+
7+
make -j "$(nproc)"
8+
make install
9+
10+
rm "$POLYSCRIPT_PATH"/polyscript-enable
11+

polyscripting/src/scrambler/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)