mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
update to Dockerfile version(1.3.0)
This commit is contained in:
parent
cdf4d4999e
commit
12b32ce1a0
@ -1,4 +1,4 @@
|
||||
from alpine:latest
|
||||
FROM alpine:latest
|
||||
|
||||
# define script basic information
|
||||
# Version of this Dockerfile
|
||||
@ -9,15 +9,8 @@ ENV USE_BACKUP=no
|
||||
|
||||
# Version of some manually-installed package
|
||||
ENV VER_PHP=7.4.19
|
||||
ENV VER_SWOOLE=4.6.7
|
||||
ENV VER_HASH=1.5
|
||||
ENV VER_INOTIFY=3.0.0
|
||||
ENV VER_REDIS=5.3.4
|
||||
ENV VER_LIBXML2=2.9.12
|
||||
ENV VER_CURL=7.77.0
|
||||
ENV VER_LIBLZMA=master
|
||||
|
||||
# LINK_OF_ADDRESS_ORIGIN
|
||||
# APK repositories mirror address, if u r not in China, consider set USE_BACKUP=yes to boost
|
||||
ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
|
||||
ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
|
||||
|
||||
@ -30,7 +23,7 @@ RUN if [ "${USE_BACKUP}" = "yes" ]; then \
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
|
||||
|
||||
# build requirements
|
||||
RUN apk add cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
|
||||
RUN apk add wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
|
||||
# php zlib dependencies
|
||||
RUN apk add zlib-dev zlib-static
|
||||
# php mbstring dependencies
|
||||
@ -41,97 +34,38 @@ RUN apk add openssl-libs-static openssl-dev openssl
|
||||
RUN apk add libpng-dev libpng-static
|
||||
# curl c-ares dependencies
|
||||
RUN apk add c-ares-static c-ares-dev
|
||||
# php event dependencies
|
||||
RUN apk add libevent libevent-dev libevent-static
|
||||
|
||||
RUN mkdir /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ac_override_1 /app/
|
||||
COPY ac_override_2 /app/
|
||||
COPY download.sh /app/
|
||||
COPY config.json /app/
|
||||
|
||||
RUN chmod +x /app/download.sh
|
||||
|
||||
RUN ./download.sh swoole ${USE_BACKUP} && \
|
||||
./download.sh inotify ${USE_BACKUP} && \
|
||||
./download.sh mongodb ${USE_BACKUP} && \
|
||||
./download.sh event ${USE_BACKUP} && \
|
||||
./download.sh redis ${USE_BACKUP} && \
|
||||
./download.sh libxml2 ${USE_BACKUP} && \
|
||||
./download.sh liblzma ${USE_BACKUP} && \
|
||||
./download.sh curl ${USE_BACKUP}
|
||||
|
||||
RUN ./download.sh php ${USE_BACKUP} ${VER_PHP}
|
||||
|
||||
COPY extensions.txt /app/
|
||||
COPY check-extensions.sh /app/
|
||||
COPY compile-php.sh /app/
|
||||
|
||||
RUN chmod +x /app/download.sh && \
|
||||
chmod +x /app/compile-php.sh
|
||||
RUN chmod +x ./check-extensions.sh && \
|
||||
chmod +x ./compile-php.sh
|
||||
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh hash ${USE_BACKUP} ${VER_HASH}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
|
||||
|
||||
RUN wget "http://mirrors.zhamao.xin/php/php-${VER_PHP}.tar.gz" -O php.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/swoole-${VER_SWOOLE}.tgz" -O swoole.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/hash-${VER_HASH}.tgz" -O hash.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/inotify-${VER_INOTIFY}.tgz" -O inotify.tar.gz
|
||||
RUN wget "http://mirrors.zhamao.xin/pecl/redis-${VER_REDIS}.tgz" -O redis.tar.gz
|
||||
RUN wget "https://dl.zhamao.me/libxml2/libxml2-${VER_LIBXML2}.tar.gz" -O libxml2.tar.gz
|
||||
RUN wget "https://dl.zhamao.me/liblzma/liblzma.tar.gz"
|
||||
RUN wget "https://dl.zhamao.me/curl/curl-${VER_CURL}.tar.gz" -O curl.tar.gz
|
||||
|
||||
RUN tar -xf php.tar.gz && \
|
||||
tar -xf swoole.tar.gz && \
|
||||
tar -xf hash.tar.gz && \
|
||||
tar -xf inotify.tar.gz && \
|
||||
tar -xf redis.tar.gz && \
|
||||
tar -xf libxml2.tar.gz && \
|
||||
tar -xf liblzma.tar.gz && \
|
||||
tar -xf curl.tar.gz
|
||||
|
||||
RUN cd liblzma && \
|
||||
./configure && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "liblzma compiled!"
|
||||
|
||||
RUN cd "libxml2-${VER_LIBXML2}" && \
|
||||
./configure --with-lzma --without-python && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "libxml2 compiled!"
|
||||
|
||||
RUN cd "curl-${VER_CURL}" && \
|
||||
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
|
||||
--without-nghttp2 \
|
||||
--with-ssl=/usr \
|
||||
--with-pic=pic \
|
||||
--enable-ipv6 \
|
||||
--enable-shared=no \
|
||||
--without-libidn2 \
|
||||
--disable-ldap \
|
||||
--without-libpsl \
|
||||
--without-lber \
|
||||
--enable-ares && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "curl compiled!"
|
||||
|
||||
COPY ac_override_1 /
|
||||
COPY ac_override_2 /
|
||||
COPY compile-php.sh /app/
|
||||
|
||||
RUN apk add bash
|
||||
|
||||
# copy
|
||||
RUN mv "swoole-${VER_SWOOLE}" "php-${VER_PHP}/ext/swoole" && \
|
||||
mv "redis-${VER_REDIS}" "php-${VER_PHP}/ext/redis" && \
|
||||
mv "inotify-${VER_INOTIFY}" "php-${VER_PHP}/ext/inotify"
|
||||
|
||||
RUN cat /ac_override_1 /app/php-${VER_PHP}/ext/curl/config.m4 /ac_override_2 > /app/aa
|
||||
RUN mv /app/aa /app/php-${VER_PHP}/ext/curl/config.m4
|
||||
|
||||
RUN cd "php-${VER_PHP}/ext/swoole/" && \
|
||||
./clear.sh && \
|
||||
cd ../../ && \
|
||||
./buildconf --force
|
||||
RUN ./check-extensions.sh check_before_configure
|
||||
|
||||
RUN ./compile-php.sh ${VER_PHP}
|
||||
|
||||
RUN cd "php-${VER_PHP}" && \
|
||||
sed -ie 's/-export-dynamic//g' "Makefile" && \
|
||||
sed -ie 's/-o \$(SAPI_CLI_PATH)/-all-static -o \$(SAPI_CLI_PATH)/g' "Makefile" && \
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
|
||||
make LDFLAGS=-ldl -j4 && \
|
||||
make install && \
|
||||
strip
|
||||
|
||||
|
||||
229
docker/check-extensions.sh
Executable file
229
docker/check-extensions.sh
Executable file
@ -0,0 +1,229 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Here are 3 steps in configuration of extensions
|
||||
# before_configure
|
||||
# in_configure
|
||||
# after_configure
|
||||
|
||||
self_dir=$(cd "$(dirname "$0")";pwd)
|
||||
php_dir=$(find $self_dir/source -name "php-*" -type d | tail -n1)
|
||||
|
||||
function do_xml_compiler() {
|
||||
cd $self_dir/source/liblzma-* && \
|
||||
./configure && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "liblzma compiled!" && sleep 2s && \
|
||||
cd ../libxml2-* && \
|
||||
./configure --prefix=/usr --with-lzma --without-python && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "libxml2 compiled!" && sleep 2s
|
||||
}
|
||||
|
||||
function do_curl_compiler() {
|
||||
cd $self_dir/source/curl-* && \
|
||||
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
|
||||
--without-nghttp2 \
|
||||
--with-ssl=/usr \
|
||||
--with-pic=pic \
|
||||
--enable-ipv6 \
|
||||
--enable-shared=no \
|
||||
--without-libidn2 \
|
||||
--disable-ldap \
|
||||
--without-libpsl \
|
||||
--without-lber \
|
||||
--enable-ares && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
echo "curl compiled!" && \
|
||||
cat "$self_dir/ac_override_1" "$php_dir/ext/curl/config.m4" "$self_dir/ac_override_2" > /tmp/aa && \
|
||||
mv /tmp/aa "$php_dir/ext/curl/config.m4"
|
||||
}
|
||||
|
||||
function do_copy_extension() {
|
||||
ext_dir=$(find $self_dir/source -name "$1-*" -type d | tail -n1)
|
||||
mv $ext_dir $php_dir/ext/$1
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile error! ext: $1, ext_dir=$ext_dir"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function check_before_configure() {
|
||||
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
|
||||
xml_sign="no"
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
bcmath) ;;
|
||||
calendar) ;;
|
||||
ctype) ;;
|
||||
filter) ;;
|
||||
gd) ;;
|
||||
hash) ;;
|
||||
iconv) ;;
|
||||
json) ;;
|
||||
mbstring) ;;
|
||||
mysqlnd) ;;
|
||||
openssl) ;;
|
||||
pcntl) ;;
|
||||
pdo) ;;
|
||||
pdo_mysql) ;;
|
||||
phar) ;;
|
||||
posix) ;;
|
||||
sockets) ;;
|
||||
tokenizer) ;;
|
||||
zlib) ;;
|
||||
curl)
|
||||
do_curl_compiler
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile curl error!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
dom|xml|libxml|xmlreader|xmlwriter|simplexml)
|
||||
if [ "$xml_sign" = "no" ]; then
|
||||
do_xml_compiler
|
||||
if [ $? != 0 ]; then
|
||||
echo "Compile curl error!"
|
||||
exit 1
|
||||
fi
|
||||
xml_sign="yes"
|
||||
fi
|
||||
;;
|
||||
inotify) do_copy_extension inotify ;;
|
||||
redis) do_copy_extension redis ;;
|
||||
swoole) do_copy_extension swoole ;;
|
||||
mongodb) do_copy_extension mongodb ;;
|
||||
event)
|
||||
PHP_EVENT=' PHP_EVENT_PHP_VERSION=$PHP_VERSION '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_PHP_VERSION_ID=$PHP_VERSION_ID '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test -z "$PHP_EVENT_PHP_VERSION"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_ERROR(\[unknown source with no php version\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR="." '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test "$PHP_EVENT_PHP_VERSION_ID" -ge "80000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php8 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 8.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n elif test "$PHP_EVENT_PHP_VERSION_ID" -ge "70000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php7 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 7.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n elif test "$PHP_EVENT_PHP_VERSION_ID" -ge "50000"; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR=php5 '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_RESULT(\[PHP 5.x\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n else '
|
||||
PHP_EVENT="$PHP_EVENT"'\n AC_MSG_ERROR(\[unknown source lol\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_EVENT_SUBDIR="." '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
PHP_EVENT="$PHP_EVENT"'\n echo PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR '
|
||||
PHP_EVENT="$PHP_EVENT"'\n echo PHP_EXT_BUILDDIR(event)\/$PHP_EVENT_SUBDIR '
|
||||
PHP_EVENT="$PHP_EVENT"'\n if test "$PHP_EVENT_SUBDIR" -ne "."; then '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR\/classes, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_BUILD_DIR(PHP_EXT_SRCDIR(event)\/$PHP_EVENT_SUBDIR\/src, 1) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\/classes\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(event)\/\[$PHP_EVENT_SUBDIR\/src\]) '
|
||||
PHP_EVENT="$PHP_EVENT"'\n fi '
|
||||
|
||||
do_copy_extension event && \
|
||||
sed -ie 's/PHP_EVENT_SUBDIR="."//g' $php_dir/ext/event/config.m4 && \
|
||||
sed -ie 's/AC_MSG_ERROR(\[unknown source\])/'"$PHP_EVENT"'/g' $php_dir/ext/event/config.m4
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function check_in_configure() {
|
||||
php_configure=""
|
||||
list=$(cat "$self_dir/extensions.txt" | sed 's/#.*//g' | sed -e 's/[ ]*$//g' | grep -v "^\s*$")
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
bcmath) php_configure="$php_configure --enable-bcmath" ;;
|
||||
calendar) php_configure="$php_configure --enable-calendar" ;;
|
||||
ctype) php_configure="$php_configure --enable-ctype" ;;
|
||||
curl) php_configure="$php_configure --with-curl" ;;
|
||||
dom) php_configure="$php_configure --enable-dom" ;;
|
||||
event) php_configure="$php_configure --with-event-core --with-event-extra --with-event-openssl --with-event-extra --disable-event-sockets" ;;
|
||||
filter) php_configure="$php_configure --enable-filter" ;;
|
||||
gd)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --with-gd" ;;
|
||||
7.4.*|8.*) php_configure="$php_configure --enable-gd" ;;
|
||||
esac
|
||||
;;
|
||||
hash)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
|
||||
esac
|
||||
;;
|
||||
iconv) php_configure="$php_configure --with-iconv" ;;
|
||||
inotify) php_configure="$php_configure --enable-inotify" ;;
|
||||
json)
|
||||
case $1 in
|
||||
7.*) php_configure="$php_configure --enable-json" ;;
|
||||
esac
|
||||
;;
|
||||
libxml)
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-libxml" ;;
|
||||
7.4.*|8.*) php_configure="$php_configure --with-libxml" ;;
|
||||
esac
|
||||
;;
|
||||
mbstring) php_configure="$php_configure --enable-mbstring" ;;
|
||||
mongodb) php_configure="$php_configure --enable-mongodb" ;;
|
||||
mysqlnd) php_configure="$php_configure --enable-mysqlnd" ;;
|
||||
openssl) php_configure="$php_configure --with-openssl --with-openssl-dir=/usr" ;;
|
||||
pcntl) php_configure="$php_configure --enable-pcntl" ;;
|
||||
pdo) php_configure="$php_configure --enable-pdo" ;;
|
||||
pdo_mysql) php_configure="$php_configure --with-pdo-mysql=mysqlnd" ;;
|
||||
phar) php_configure="$php_configure --enable-phar" ;;
|
||||
posix) php_configure="$php_configure --enable-posix" ;;
|
||||
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
|
||||
simplexml) php_configure="$php_configure --enable-simplexml" ;;
|
||||
sockets) php_configure="$php_configure --enable-sockets" ;;
|
||||
swoole)
|
||||
php_configure="$php_configure --enable-swoole"
|
||||
have_openssl=$(echo $list | grep openssl)
|
||||
if [ "$have_openssl" != "" ]; then
|
||||
php_configure="$php_configure --enable-openssl --with-openssl --with-openssl-dir=/usr"
|
||||
fi
|
||||
have_hash=$(echo $list | grep hash)
|
||||
if [ "$have_hash" = "" ]; then
|
||||
case $1 in
|
||||
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
tokenizer) php_configure="$php_configure --enable-tokenizer" ;;
|
||||
xml) php_configure="$php_configure --enable-xml" ;;
|
||||
xmlreader) php_configure="$php_configure --enable-xmlreader" ;;
|
||||
xmlwriter) php_configure="$php_configure --enable-xmlwriter" ;;
|
||||
zlib) php_configure="$php_configure --with-zlib" ;;
|
||||
*)
|
||||
echo "Unsupported extension '$loop' !" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo $php_configure
|
||||
}
|
||||
|
||||
function check_after_configure() {
|
||||
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
|
||||
for loop in $list
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$php_dir/ext/swoole/include/swoole.h"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
$1 $2
|
||||
75
docker/compile-php.sh
Normal file → Executable file
75
docker/compile-php.sh
Normal file → Executable file
@ -2,6 +2,9 @@
|
||||
|
||||
VER_PHP="$1"
|
||||
|
||||
self_dir=$(cd "$(dirname "$0")";pwd)
|
||||
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
|
||||
|
||||
function php_compile_args() {
|
||||
_php_arg="--prefix=/app/php-dist"
|
||||
_php_arg="$_php_arg --disable-all"
|
||||
@ -9,79 +12,21 @@ function php_compile_args() {
|
||||
_php_arg="$_php_arg --enable-static=yes"
|
||||
_php_arg="$_php_arg --enable-inline-optimization"
|
||||
_php_arg="$_php_arg --with-layout=GNU"
|
||||
_php_arg="$_php_arg --enable-calendar"
|
||||
_php_arg="$_php_arg --enable-ctype"
|
||||
_php_arg="$_php_arg --enable-filter"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --enable-bcmath"
|
||||
_php_arg="$_php_arg --enable-pcntl"
|
||||
_php_arg="$_php_arg --enable-openssl"
|
||||
_php_arg="$_php_arg --with-openssl"
|
||||
_php_arg="$_php_arg --with-iconv"
|
||||
_php_arg="$_php_arg --enable-mbstring"
|
||||
_php_arg="$_php_arg --enable-phar"
|
||||
_php_arg="$_php_arg --enable-pdo"
|
||||
_php_arg="$_php_arg --with-pdo-mysql=mysqlnd"
|
||||
_php_arg="$_php_arg --enable-sockets"
|
||||
_php_arg="$_php_arg --enable-swoole"
|
||||
_php_arg="$_php_arg --enable-inotify"
|
||||
_php_arg="$_php_arg --enable-redis"
|
||||
_php_arg="$_php_arg --disable-redis-session"
|
||||
_php_arg="$_php_arg --enable-simplexml"
|
||||
_php_arg="$_php_arg --enable-dom"
|
||||
_php_arg="$_php_arg --enable-xml"
|
||||
_php_arg="$_php_arg --enable-xmlwriter"
|
||||
_php_arg="$_php_arg --enable-xmlreader"
|
||||
_php_arg="$_php_arg --with-zlib"
|
||||
_php_arg="$_php_arg --enable-posix"
|
||||
_php_arg="$_php_arg --enable-mysqlnd"
|
||||
_php_arg="$_php_arg --enable-tokenizer"
|
||||
_php_arg="$_php_arg --with-curl"
|
||||
_php_arg="$_php_arg --with-pear=no"
|
||||
_php_arg="$_php_arg --disable-cgi"
|
||||
_php_arg="$_php_arg --disable-phpdbg"
|
||||
|
||||
for loop in $(cat extension.txt)
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
esac
|
||||
done
|
||||
|
||||
case $1 in
|
||||
7.3.*|7.2.*)
|
||||
_php_arg="$_php_arg --with-gd"
|
||||
_php_arg="$_php_arg --enable-libxml"
|
||||
_php_arg="$_php_arg --enable-hash"
|
||||
_php_arg="$_php_arg --enable-json"
|
||||
;;
|
||||
7.4.*)
|
||||
_php_arg="$_php_arg --enable-gd"
|
||||
_php_arg="$_php_arg --with-libxml"
|
||||
_php_arg="$_php_arg --enable-json"
|
||||
;;
|
||||
8.*)
|
||||
_php_arg="$_php_arg --enable-gd"
|
||||
_php_arg="$_php_arg --with-libxml"
|
||||
;;
|
||||
esac
|
||||
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
|
||||
echo $_php_arg
|
||||
}
|
||||
|
||||
function before_configure() {
|
||||
for loop in $(cat extension.txt)
|
||||
do
|
||||
case $loop in
|
||||
swoole)
|
||||
esac
|
||||
done
|
||||
}
|
||||
php_compile_args && sleep 1s
|
||||
|
||||
cd php-$VER_PHP && \
|
||||
before_configure && \
|
||||
cd $php_dir && \
|
||||
./buildconf --force && \
|
||||
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
|
||||
after_configure && \
|
||||
$self_dir/check-extensions.sh check_after_configure && \
|
||||
sed -ie 's/-export-dynamic//g' "Makefile" && \
|
||||
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
|
||||
if [ "$(cat extension.txt | grep swoole)" != "" ]; then sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
|
||||
make LDFLAGS=-ldl -j4 && \
|
||||
make install && \
|
||||
strip /app/php-dist/bin/php
|
||||
@ -1,3 +1,46 @@
|
||||
swoole
|
||||
redis
|
||||
hello
|
||||
{
|
||||
"php": {
|
||||
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
|
||||
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
|
||||
},
|
||||
"swoole": {
|
||||
"version": "4.6.7",
|
||||
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
|
||||
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "1.9.1",
|
||||
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
|
||||
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
|
||||
},
|
||||
"inotify": {
|
||||
"version": "3.0.0",
|
||||
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
|
||||
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
|
||||
},
|
||||
"event": {
|
||||
"version": "3.0.4",
|
||||
"link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz",
|
||||
"link_2": "https://pecl.php.net/get/event-{version}.tgz"
|
||||
},
|
||||
"redis": {
|
||||
"version": "5.3.4",
|
||||
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
|
||||
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
|
||||
},
|
||||
"libxml2": {
|
||||
"version": "2.9.10",
|
||||
"link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz",
|
||||
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
|
||||
},
|
||||
"liblzma": {
|
||||
"version": "master",
|
||||
"link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz",
|
||||
"link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip"
|
||||
},
|
||||
"curl": {
|
||||
"version": "7.77.0",
|
||||
"link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz",
|
||||
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
|
||||
}
|
||||
}
|
||||
138
docker/download.sh
Normal file → Executable file
138
docker/download.sh
Normal file → Executable file
@ -2,108 +2,42 @@
|
||||
|
||||
_use_backup="$2"
|
||||
|
||||
function download_file() {
|
||||
downloader="wget"
|
||||
type wget >/dev/null 2>&1 || { downloader="curl"; }
|
||||
if [ "$downloader" = "wget" ]; then
|
||||
_down_prefix="O"
|
||||
else
|
||||
_down_prefix="o"
|
||||
fi
|
||||
_down_symbol=0
|
||||
if [ ! -f "$2" ]; then
|
||||
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
|
||||
echo "$1 完成! $2" && _down_symbol=1
|
||||
else
|
||||
echo "$2 已存在!" && _down_symbol=1
|
||||
fi
|
||||
if [ $_down_symbol == 0 ]; then
|
||||
echo "下载 $1 失败!请检查网络连接!"
|
||||
rm -rf "$2"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
SELF_DIR=$(cd "$(dirname "$0")";pwd)
|
||||
|
||||
if [ ! -d "source" ]; then
|
||||
mkdir source
|
||||
fi
|
||||
|
||||
function readconf() {
|
||||
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
|
||||
}
|
||||
|
||||
function lib_download_link() {
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
case $1 in
|
||||
"php") echo "https://www.php.net/distributions/php-$2.tar.gz" ;;
|
||||
"swoole") echo "https://pecl.php.net/get/swoole-$2.tgz" ;;
|
||||
"hash") echo "https://pecl.php.net/get/hash-$2.tgz" ;;
|
||||
"inotify") echo "https://pecl.php.net/get/inotify-$2.tgz" ;;
|
||||
"redis") echo "https://pecl.php.net/get/redis-$2.tgz" ;;
|
||||
"libxml2") echo "http://xmlsoft.org/sources/libxml2-$2.tar.gz" ;;
|
||||
"liblzma") echo "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip" ;;
|
||||
"curl") echo "https://curl.haxx.se/download/curl-$2.tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"php") echo "http://mirrors.zhamao.xin/php/php-$2.tar.gz" ;;
|
||||
"swoole") echo "http://mirrors.zhamao.xin/pecl/swoole-$2.tgz" ;;
|
||||
"hash") echo "http://mirrors.zhamao.xin/pecl/hash-$2.tgz" ;;
|
||||
"inotify") echo "http://mirrors.zhamao.xin/pecl/inotify-$2.tgz" ;;
|
||||
"redis") echo "http://mirrors.zhamao.xin/pecl/redis-$2.tgz" ;;
|
||||
"libxml2") echo "https://dl.zhamao.me/libxml2/libxml2-$2.tar.gz" ;;
|
||||
"liblzma") echo "https://dl.zhamao.me/liblzma/liblzma.tar.gz" ;;
|
||||
"curl") echo "https://dl.zhamao.me/curl/curl-$2.tar.gz" ;;
|
||||
*) echo "unknown" ;;
|
||||
esac
|
||||
cd source
|
||||
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
_use_backup="_2"
|
||||
else
|
||||
_use_backup=""
|
||||
fi
|
||||
|
||||
if [ "$3" != "" ]; then
|
||||
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
|
||||
else
|
||||
wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
|
||||
fi
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1)
|
||||
archive_file_zip=$(find . -name "$1*.*" | grep -E ".zip" | tail -n1)
|
||||
if [ "$archive_file_tar" != "" ]; then
|
||||
tar -zxvf $archive_file_tar && rm $archive_file_tar
|
||||
elif [ "$archive_file_zip" != "" ]; then
|
||||
unzip $archive_file_zip && rm $archive_file_zip
|
||||
else
|
||||
echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function lib_x_cmd() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
_x_cmd="tar"
|
||||
;;
|
||||
"liblzma") if [ "$_use_backup" = "yes" ]; then _x_cmd="unzip"; else _x_cmd="tar"; fi ;;
|
||||
*) _x_cmd="unknown" ;;
|
||||
esac
|
||||
case $2 in
|
||||
"cmd")
|
||||
echo $_x_cmd
|
||||
;;
|
||||
"file-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-zxvf" ;;
|
||||
"unzip") echo "" ;;
|
||||
esac
|
||||
;;
|
||||
"out-prefix")
|
||||
case $_x_cmd in
|
||||
"tar") echo "-C" ;;
|
||||
"unzip") echo "-d" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function lib_x() {
|
||||
$(lib_x_cmd $1 cmd) $(lib_x_cmd $1 file-prefix) "$_source_dir/$(lib_x_dirname $1 file)" $(lib_x_cmd $1 out-prefix) "$_source_dir/"
|
||||
}
|
||||
|
||||
# 获取解压后的源码根目录
|
||||
function lib_x_dirname() {
|
||||
case $1 in
|
||||
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
;;
|
||||
"liblzma")
|
||||
if [ "$_use_backup" = "yes" ]; then
|
||||
if [ "$2" = "file" ]; then _name_prefix=".zip"; else _name_prefix=""; fi
|
||||
echo "$1-$(lib_ver $1)$_name_prefix"
|
||||
else
|
||||
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
|
||||
echo "$1""$_name_prefix"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "unknown"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
download_file $(lib_download_link $1 $3) $(lib_x_firname $1 file)
|
||||
else
|
||||
echo "Download failed! "
|
||||
exit 1
|
||||
fi
|
||||
30
docker/extensions.txt
Normal file
30
docker/extensions.txt
Normal file
@ -0,0 +1,30 @@
|
||||
bcmath
|
||||
calendar
|
||||
ctype
|
||||
curl
|
||||
dom
|
||||
filter
|
||||
gd
|
||||
hash
|
||||
iconv
|
||||
inotify
|
||||
json
|
||||
libxml
|
||||
mbstring
|
||||
#mongodb
|
||||
mysqlnd
|
||||
openssl
|
||||
pcntl
|
||||
pdo
|
||||
pdo_mysql
|
||||
phar
|
||||
posix
|
||||
redis
|
||||
simplexml
|
||||
sockets
|
||||
swoole
|
||||
tokenizer
|
||||
xml
|
||||
xmlreader
|
||||
xmlwriter
|
||||
zlib
|
||||
Loading…
x
Reference in New Issue
Block a user