mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
add micro php build
This commit is contained in:
parent
4cba2cb8c1
commit
74060cbf27
17
.github/workflows/build-php.yml
vendored
17
.github/workflows/build-php.yml
vendored
@ -30,10 +30,25 @@ jobs:
|
||||
fi
|
||||
- name: Build PHP ${{ matrix.php-versions }} for ${{ matrix.arch }}
|
||||
run: cd docker/ && docker build . --file Dockerfile --tag static-php --build-arg USE_BACKUP_ADDRESS=yes --build-arg COMPILE_PHP_VERSION=${{ matrix.php-versions }}
|
||||
- name: Build micro PHP distribution ${{ matrix.php-versions }} for ${{ matrix.arch }}
|
||||
run: |
|
||||
if [[ "${{ matrix.arch }}" = "x86_64" ]]; then
|
||||
MAIN_VERSION=$(echo "${{ matrix.php-versions }}" | awk -F. '{print $1}')
|
||||
if [[ "$MAIN_VERSION" = "8" ]]; then
|
||||
cd docker/ && docker build . --file Dockerfile --tag static-micro --build-arg USE_BACKUP_ADDRESS=yes --build-arg COMPILE_PHP_VERSION=${{ matrix.php-versions }} --build-arg COMPILE_MICRO=yes
|
||||
fi
|
||||
fi
|
||||
- name: Push PHP ${{ matrix.php-versions }} to dist
|
||||
run: |
|
||||
mkdir dist && docker run --rm -v $(pwd)/dist:/dist/ static-php cp php-dist/bin/php /dist/
|
||||
cd dist && tar -zcvf "php-${{ matrix.php-versions }}-static-bin-${{ matrix.arch }}.tar.gz" ./php && rm ./php
|
||||
cd dist && tar -zcvf "php-${{ matrix.php-versions }}-static-bin-${{ matrix.arch }}.tar.gz" ./php && rm ./php && cd ..
|
||||
if [[ "${{ matrix.arch }}" = "x86_64" ]]; then
|
||||
MAIN_VERSION=$(echo "${{ matrix.php-versions }}" | awk -F. '{print $1}')
|
||||
if [[ "$MAIN_VERSION" = "8" ]]; then
|
||||
docker run --rm -v $(pwd)/dist:/dist static-micro cp /app/source/php-"${{ matrix.php-versions }}"/sapi/micro/micro.sfx /dist/
|
||||
cd dist && tar -zcvf "micro-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz" ./micro.sfx && rm ./micro.sfx && cd ..
|
||||
fi
|
||||
fi
|
||||
- name: Deploy to Zhamao Server
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
|
||||
@ -2,11 +2,12 @@ FROM alpine:latest
|
||||
|
||||
# define script basic information
|
||||
# Version of this Dockerfile
|
||||
ENV SCRIPT_VERSION=1.4.3
|
||||
ENV SCRIPT_VERSION=1.5.0
|
||||
# Download address uses backup address
|
||||
|
||||
ARG USE_BACKUP_ADDRESS
|
||||
ARG COMPILE_PHP_VERSION
|
||||
ARG COMPILE_MICRO
|
||||
|
||||
# (if downloading slowly, consider set it to yes)
|
||||
ENV USE_BACKUP="${USE_BACKUP_ADDRESS}"
|
||||
@ -14,6 +15,8 @@ ENV USE_BACKUP="${USE_BACKUP_ADDRESS}"
|
||||
# Version of some manually-installed package
|
||||
ENV VER_PHP="${COMPILE_PHP_VERSION}"
|
||||
|
||||
ENV ENABLE_MICRO="${COMPILE_MICRO}"
|
||||
|
||||
# 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'
|
||||
@ -45,6 +48,8 @@ RUN apk add libevent libevent-dev libevent-static > /dev/null
|
||||
RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static > /dev/null
|
||||
# php libzip dependencies
|
||||
RUN apk add bzip2-dev bzip2-static bzip2
|
||||
# php micro ffi dependencies
|
||||
RUN apk add libffi libffi-dev
|
||||
|
||||
RUN mkdir /app
|
||||
|
||||
@ -76,10 +81,15 @@ COPY check-extensions.sh /app/
|
||||
COPY compile-php.sh /app/
|
||||
|
||||
RUN chmod +x ./check-extensions.sh && \
|
||||
chmod +x ./compile-php.sh
|
||||
chmod +x ./compile-php.sh && \
|
||||
chmod +x ./compile-micro.sh
|
||||
|
||||
RUN echo "Checking and Compiling Dependencies ..."
|
||||
RUN ./check-extensions.sh check_before_configure > /dev/null
|
||||
|
||||
RUN echo "Compiling PHP ..."
|
||||
RUN ./compile-php.sh ${VER_PHP} > /dev/null 2>&1
|
||||
RUN if [ "${ENABLE_MICRO}" = "yes" ]; then \
|
||||
./compile-micro.sh ${VER_PHP} > /dev/null 2>&1 ; \
|
||||
else \
|
||||
./compile-php.sh ${VER_PHP} > /dev/null 2>&1 ; \
|
||||
fi
|
||||
|
||||
@ -260,6 +260,7 @@ function check_after_configure() {
|
||||
case $loop in
|
||||
swoole)
|
||||
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$php_dir/ext/swoole/include/swoole.h"
|
||||
sed -ie 's/strcmp("cli", sapi_module.name) == 0/strcmp("cli", sapi_module.name) == 0 || strcmp("micro", sapi_module.name) == 0/g' "$php_dir/ext/swoole/ext-src/php_swoole.cc"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
38
docker/compile-micro.sh
Executable file
38
docker/compile-micro.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
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=$self_dir/php-dist"
|
||||
_php_arg="$_php_arg --disable-all"
|
||||
_php_arg="$_php_arg --enable-shared=no"
|
||||
_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 --with-pear=no"
|
||||
_php_arg="$_php_arg --disable-cgi"
|
||||
_php_arg="$_php_arg --disable-phpdbg"
|
||||
_php_arg="$_php_arg --with-ffi"
|
||||
_php_arg="$_php_arg --enable-micro"
|
||||
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
|
||||
echo $_php_arg
|
||||
}
|
||||
|
||||
php_compile_args && sleep 1s
|
||||
|
||||
cd $php_dir && \
|
||||
git clone https://github.com/dixyes/phpmicro.git --depth=1 sapi/micro && \
|
||||
./buildconf --force && \
|
||||
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
|
||||
$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" && \
|
||||
sed -ie 's/-o $(SAPI_MICRO_PATH)/-all-static -o $(SAPI_MICRO_PATH)/g' "Makefile" && \
|
||||
sed -ie 's/$(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MICRO_OBJS)/$(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_BINARY_OBJS:.lo=.o) $(PHP_MICRO_OBJS:.lo=.o)/g' "Makefile" && \
|
||||
sed -ie 's/$(EXTRA_LIBS:-lresolv=-Wl,-Bstatic,-lresolv,-Bdynamic)/$(EXTRA_LIBS)/g' "Makefile" && \
|
||||
make micro LDFLAGS="-static" -j$(cat /proc/cpuinfo | grep processor | wc -l)
|
||||
#make install
|
||||
#strip $self_dir/php-dist/bin/php
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
# This script needs alpine linux system.
|
||||
|
||||
test "$VER_PHP" = "" && VER_PHP="7.4.28"
|
||||
test "$VER_PHP" = "" && VER_PHP="8.1.6"
|
||||
test "$USE_BACKUP" = "" && USE_BACKUP="no"
|
||||
|
||||
LINK_APK_REPO='mirrors.ustc.edu.cn'
|
||||
@ -35,8 +35,10 @@ apk add libevent libevent-dev libevent-static
|
||||
apk add sqlite sqlite-dev sqlite-libs sqlite-static
|
||||
# php libzip dependencies
|
||||
apk add bzip2-dev bzip2-static bzip2
|
||||
# php micro ffi dependencies
|
||||
apk add libffi libffi-dev
|
||||
|
||||
chmod +x download.sh check-extensions.sh compile-php.sh
|
||||
chmod +x download.sh check-extensions.sh compile-php.sh compile-micro.sh
|
||||
|
||||
./download.sh swoole ${USE_BACKUP} && \
|
||||
./download.sh inotify ${USE_BACKUP} && \
|
||||
@ -49,5 +51,5 @@ chmod +x download.sh check-extensions.sh compile-php.sh
|
||||
./download.sh libzip ${USE_BACKUP} && \
|
||||
./download.sh php ${USE_BACKUP} ${VER_PHP} && \
|
||||
./check-extensions.sh check_before_configure && \
|
||||
./compile-php.sh ${VER_PHP}
|
||||
./compile-micro.sh ${VER_PHP}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user