mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 21:04:52 +08:00
Update gnu-docker and fix icu build on glibc
This commit is contained in:
parent
23bfad6f87
commit
4eeb48cdc2
5
bin/spc
5
bin/spc
@ -4,6 +4,11 @@
|
|||||||
use SPC\ConsoleApplication;
|
use SPC\ConsoleApplication;
|
||||||
use SPC\exception\ExceptionHandler;
|
use SPC\exception\ExceptionHandler;
|
||||||
|
|
||||||
|
// Load custom php if exists
|
||||||
|
if (PHP_OS_FAMILY !== 'Windows' && PHP_BINARY !== (__DIR__ . '/php') && file_exists(__DIR__ . '/php') && is_executable(__DIR__ . '/php')) {
|
||||||
|
pcntl_exec(__DIR__ . '/php', $argv);
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
|
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
|
||||||
// Current: ./bin (git/project mode)
|
// Current: ./bin (git/project mode)
|
||||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|||||||
@ -119,4 +119,8 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
|||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
# shellcheck disable=SC2090
|
# shellcheck disable=SC2090
|
||||||
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-v2 bin/spc $@
|
if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then
|
||||||
|
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-v2
|
||||||
|
else
|
||||||
|
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-v2 bin/spc $@
|
||||||
|
fi
|
||||||
|
|||||||
@ -59,6 +59,22 @@ RUN yum clean all && \
|
|||||||
yum makecache && \
|
yum makecache && \
|
||||||
yum update -y
|
yum update -y
|
||||||
|
|
||||||
|
RUN yum install -y centos-release-scl
|
||||||
|
|
||||||
|
RUN if [ "$BASE_ARCH" = "aarch64" ]; then \
|
||||||
|
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ; \
|
||||||
|
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl.repo ; \
|
||||||
|
else \
|
||||||
|
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
|
||||||
|
fi
|
||||||
|
RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
|
||||||
|
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
|
||||||
|
|
||||||
|
RUN yum update -y && \
|
||||||
|
yum install -y devtoolset-7-gcc-*
|
||||||
|
RUN echo "source scl_source enable devtoolset-7" >> /etc/bashrc
|
||||||
|
RUN source /etc/bashrc
|
||||||
|
|
||||||
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
|
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
|
||||||
mkdir /cmake && \
|
mkdir /cmake && \
|
||||||
tar -xzf cmake.tgz -C /cmake --strip-components 1
|
tar -xzf cmake.tgz -C /cmake --strip-components 1
|
||||||
@ -73,9 +89,9 @@ RUN /app/bin/php /app/bin/composer install --no-dev --classmap-authoritative
|
|||||||
ENV PATH="/app/bin:/cmake/bin:$PATH"
|
ENV PATH="/app/bin:/cmake/bin:$PATH"
|
||||||
ENV SPC_SKIP_DOCTOR_CHECK_ITEMS="if musl-wrapper is installed,if musl-cross-make is installed"
|
ENV SPC_SKIP_DOCTOR_CHECK_ITEMS="if musl-wrapper is installed,if musl-cross-make is installed"
|
||||||
|
|
||||||
|
|
||||||
ADD ./config/env.ini /app/config/env.ini
|
ADD ./config/env.ini /app/config/env.ini
|
||||||
RUN bin/spc doctor --auto-fix --debug
|
RUN bin/spc doctor --auto-fix --debug
|
||||||
|
RUN git clone https://github.com/dunglas/frankenphp.git --depth=1 /frankenphp
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -97,8 +113,20 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
|
|||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
||||||
|
|
||||||
|
# Apply env in temp env file
|
||||||
|
echo 'SPC_SKIP_DOCTOR_CHECK_ITEMS="if musl-wrapper is installed,if musl-cross-make is installed"' > /tmp/spc-gnu-docker.env
|
||||||
|
echo 'CC=/opt/rh/devtoolset-7/root/usr/bin/gcc' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'CXX=/opt/rh/devtoolset-7/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'AR=/opt/rh/devtoolset-7/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'LD=/opt/rh/devtoolset-7/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'SPC_DEFAULT_C_FLAGS=-fPIC' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'SPC_NO_MUSL_PATH=yes' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
|
||||||
|
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil"' >> /tmp/spc-gnu-docker.env
|
||||||
|
|
||||||
# Run docker
|
# Run docker
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
# shellcheck disable=SC2090
|
# shellcheck disable=SC2090
|
||||||
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH bin/spc $@
|
|
||||||
|
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH # bin/spc $@
|
||||||
|
|||||||
@ -34,25 +34,6 @@ but **statically linked with all other dependencies**.
|
|||||||
The latest version of static-php-cli includes the `bin/spc-gnu-docker` script,
|
The latest version of static-php-cli includes the `bin/spc-gnu-docker` script,
|
||||||
which can create a CentOS 7.x (glibc-2.17) Docker container with one click and build a glibc compatible PHP static binary in the container.
|
which can create a CentOS 7.x (glibc-2.17) Docker container with one click and build a glibc compatible PHP static binary in the container.
|
||||||
|
|
||||||
First, clone the repository of this project and add the following content to the `config/env.custom.ini` file:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
; Modify this file name to `env.custom.ini`, and run `bin/spc-gnu-docker`,
|
|
||||||
; you can compile a GNU libc based static binary !
|
|
||||||
[global]
|
|
||||||
SPC_SKIP_DOCTOR_CHECK_ITEMS="if musl-wrapper is installed,if musl-cross-make is installed"
|
|
||||||
|
|
||||||
[linux]
|
|
||||||
CC=gcc
|
|
||||||
CXX=g++
|
|
||||||
AR=ar
|
|
||||||
LD=ld
|
|
||||||
SPC_DEFAULT_C_FLAGS=-fPIC
|
|
||||||
SPC_NO_MUSL_PATH=yes
|
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"
|
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil"
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, run the following command once.
|
Then, run the following command once.
|
||||||
The first run will take a long time because it needs to download the CentOS 7.x image and some build tools.
|
The first run will take a long time because it needs to download the CentOS 7.x image and some build tools.
|
||||||
|
|
||||||
|
|||||||
@ -29,25 +29,6 @@ musl-libc 是一个轻量级的 libc 实现,它的目标是与 glibc 兼容,
|
|||||||
|
|
||||||
最新版的 static-php-cli 内置了 `bin/spc-gnu-docker` 脚本,可以一键创建一个 CentOS 7.x (glibc-2.17) 的 Docker 容器,并在容器中构建 glibc 兼容的 PHP 静态二进制文件。
|
最新版的 static-php-cli 内置了 `bin/spc-gnu-docker` 脚本,可以一键创建一个 CentOS 7.x (glibc-2.17) 的 Docker 容器,并在容器中构建 glibc 兼容的 PHP 静态二进制文件。
|
||||||
|
|
||||||
请先克隆本项目的仓库,并将下面的内容添加到 `config/env.custom.ini` 文件中:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
; Modify this file name to `env.custom.ini`, and run `bin/spc-gnu-docker`,
|
|
||||||
; you can compile a GNU libc based static binary !
|
|
||||||
[global]
|
|
||||||
SPC_SKIP_DOCTOR_CHECK_ITEMS="if musl-wrapper is installed,if musl-cross-make is installed"
|
|
||||||
|
|
||||||
[linux]
|
|
||||||
CC=gcc
|
|
||||||
CXX=g++
|
|
||||||
AR=ar
|
|
||||||
LD=ld
|
|
||||||
SPC_DEFAULT_C_FLAGS=-fPIC
|
|
||||||
SPC_NO_MUSL_PATH=yes
|
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"
|
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil"
|
|
||||||
```
|
|
||||||
|
|
||||||
然后,先运行一次以下命令。首次运行时时间较长,因为需要下载 CentOS 7.x 的镜像和一些编译工具。
|
然后,先运行一次以下命令。首次运行时时间较长,因为需要下载 CentOS 7.x 的镜像和一些编译工具。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class icu extends LinuxLibraryBase
|
|||||||
{
|
{
|
||||||
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
|
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
|
||||||
$cxxflags = 'CXXFLAGS="-std=c++17"';
|
$cxxflags = 'CXXFLAGS="-std=c++17"';
|
||||||
$ldflags = 'LDFLAGS="-static"';
|
$ldflags = $this->builder->libc !== 'glibc' ? 'LDFLAGS="-static"' : '';
|
||||||
shell()->cd($this->source_dir . '/source')
|
shell()->cd($this->source_dir . '/source')
|
||||||
->exec(
|
->exec(
|
||||||
"{$cppflags} {$cxxflags} {$ldflags} " .
|
"{$cppflags} {$cxxflags} {$ldflags} " .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user