Skip to content

Commit f9b6d34

Browse files
authored
Merge pull request #917 from jingjingxyk/experiment-feature
Experiment feature
2 parents 3295688 + 3804a1b commit f9b6d34

18 files changed

+190
-25
lines changed

.github/workflows/linux-x86_64.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
export PATH=/usr/libexec/docker/cli-plugins/:$PATH
159159
docker-compose version
160160
docker container ls -a
161-
bash sapi/src/UnitTest/scripts/database/start.sh
161+
bash sapi/docker/database/start.sh
162162
163163
- name: Show Build Result
164164
run: |

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,26 @@ bash setup-php-runtime.sh
8585
# 来自 https://www.swoole.com/download
8686
bash setup-php-runtime.sh --mirror china
8787

88+
# 使用swoole-cli
89+
# shell脚本中启用别名扩展功能‌
90+
shopt -s expand_aliases
91+
__DIR__=$(pwd)
92+
export PATH="${__DIR__}/bin/runtime:$PATH"
93+
ln -sf ${__DIR__}/bin/runtime/swoole-cli ${__DIR__}/bin/runtime/php
94+
alias php="php -d curl.cainfo=${__DIR__}/bin/runtime/cacert.pem -d openssl.cafile=${__DIR__}/bin/runtime/cacert.pem"
95+
which php
96+
php -v
97+
8898
```
8999

90100
## 生成构建脚本
91101

92102
```shell
103+
93104
composer install
94105
php prepare.php
95106
php prepare.php +inotify +mongodb -mysqli
107+
96108
```
97109

98110
* 脚本会自动下载相关的`C/C++`库以及`PECL`扩展

build-release-example.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ if [ ! -f "${__PROJECT__}/bin/runtime/php" ]; then
172172
fi
173173

174174
export PATH="${__PROJECT__}/bin/runtime:$PATH"
175+
# 交互模式下alias 扩展默认是开启的,脚本模式下默认是关闭的
176+
# 在shell脚本中启用别名扩展功能‌
177+
shopt -s expand_aliases
175178
alias php="php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem"
176179

177180
php -v
@@ -219,7 +222,7 @@ if [ ${IN_DOCKER} -eq 1 ]; then
219222
{
220223
# 容器中
221224

222-
php prepare.php +inotify ${OPTIONS}
225+
php prepare.php ${OPTIONS}
223226

224227
}
225228
else

sapi/docker/build-export-container.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ done
5151

5252
case "$MIRROR" in
5353
china | openatom)
54-
CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18"
54+
CONTAINER_BASE_IMAGE="docker.io/library/alpine:3.18"
5555
;;
5656
esac
5757

sapi/src/UnitTest/scripts/database/docker-compose.yaml sapi/docker/database/docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22
services:
33
postgresql-server:
4-
image: postgres:16-alpine
4+
image: postgres:17-alpine
55
# image: postgis/postgis:16-3.4-alpine
66
hostname: "postgresql"
77
container_name: "postgresql"

sapi/docker/database/my.cnf

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
[client]
3+
default-character-set=utf8mb4
4+
[mysql]
5+
default-character-set=utf8mb4
6+
7+
[mysqld]
8+
skip_ssl
9+
skip-ssl-session-cache-mode
10+
11+
# bind-address = 0.0.0.0
12+
bind-address = 0.0.0.0
13+
# bind-address = ::
14+
15+
# 跳过密码登录
16+
# skip-grant-tables
17+
18+
collation-server = utf8mb4_unicode_ci
19+
init-connect='SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'
20+
character-set-server = utf8mb4
21+
innodb_ft_min_token_size = 1
22+
ft_min_word_len = 1
23+
innodb_ft_enable_stopword = OFF
24+
ft_stopword_file = ''
25+
26+
27+
File renamed without changes.
File renamed without changes.

sapi/quickstart/linux/install-docker-compose.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ if [ ! -f /usr/libexec/docker/cli-plugins/docker-compose ]; then
2424

2525
# show more version info
2626
# https://github.com/docker/compose/releases
27-
VERSION="v2.32.1"
27+
VERSION="v2.32.4"
2828

2929
curl -fsSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
3030

3131
chmod +x /usr/local/bin/docker-compose
3232

3333
else
34-
export PATH=/usr/libexec/docker/cli-plugins/:$PATH
34+
# export PATH=/usr/libexec/docker/cli-plugins/:$PATH
35+
ln -sf /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
3536
fi
3637

3738
docker-compose --version

sapi/quickstart/linux/run-alpine-container.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ while [ $# -gt 0 ]; do
2828
MIRROR="$2"
2929
case "$MIRROR" in
3030
china | openatom)
31-
IMAGE="hub.atomgit.com/library/alpine:3.18"
31+
IMAGE="docker.io/library/alpine:3.18"
3232
;;
3333
esac
3434
;;

sapi/quickstart/linux/run-debian-container.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ while [ $# -gt 0 ]; do
2828
MIRROR="$2"
2929
case "$MIRROR" in
3030
china | openatom)
31-
IMAGE="hub.atomgit.com/library/debian:12"
31+
IMAGE="docker.io/library/debian:12"
3232
;;
3333
esac
3434
;;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/env bash
2+
3+
set -exu
4+
__DIR__=$(
5+
cd "$(dirname "$0")"
6+
pwd
7+
)
8+
__PROJECT__=$(
9+
cd ${__DIR__}/../../
10+
pwd
11+
)
12+
13+
cd ${__DIR__}
14+
cd ${__PROJECT__}
15+
16+
test -d var/build-swoole-cli-container/ && rm -rf var/build-swoole-cli-container/
17+
mkdir -p var/build-swoole-cli-container/
18+
cd ${__PROJECT__}/var/build-swoole-cli-container/
19+
20+
cp -f ${__PROJECT__}/setup-swoole-cli-runtime.sh .
21+
22+
VERSION="6.0.0.0"
23+
bash setup-swoole-cli-runtime.sh --version v${VERSION}
24+
25+
cat >php.ini <<'EOF'
26+
curl.cainfo="/usr/local/swoole-cli/etc/cacert.pem"
27+
openssl.cafile="/usr/local/swoole-cli/etc/cacert.pem"
28+
swoole.use_shortname=off
29+
display_errors = On
30+
error_reporting = E_ALL
31+
32+
upload_max_filesize="128M"
33+
post_max_size="128M"
34+
memory_limit="1G"
35+
date.timezone="UTC"
36+
37+
opcache.enable=On
38+
opcache.enable_cli=On
39+
opcache.jit=1225
40+
opcache.jit_buffer_size=128M
41+
42+
; jit 更多配置参考 https://mp.weixin.qq.com/s/Tm-6XVGQSlz0vDENLB3ylA
43+
44+
expose_php=Off
45+
apc.enable_cli=1
46+
47+
EOF
48+
49+
cat >Dockerfile <<'EOF'
50+
FROM alpine:3.20
51+
52+
ENV TZ=Etc/UTC
53+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
54+
55+
RUN mkdir -p /usr/local/swoole-cli/etc/conf.d/
56+
ADD ./bin/runtime/swoole-cli /usr/local/bin/
57+
ADD ./bin/runtime/composer /usr/local/bin/
58+
ADD ./bin/runtime/cacert.pem /usr/local/swoole-cli/etc/
59+
ADD ./php.ini /usr/local/swoole-cli/etc/
60+
61+
RUN chmod a+x /usr/local/bin/swoole-cli
62+
RUN chmod a+x /usr/local/bin/composer
63+
RUN ln -sf /usr/local/bin/swoole-cli /usr/local/bin/php
64+
65+
ARG MIRROR=""
66+
RUN test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
67+
RUN if [ "${MIRROR}" = "ustc" -o "${MIRROR}" = "china" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; } fi
68+
RUN if [ "${MIRROR}" = "tuna" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories ; } fi
69+
70+
RUN apk add ca-certificates tini bash
71+
72+
RUN mkdir /work
73+
WORKDIR /work
74+
ENTRYPOINT ["tini", "--"]
75+
76+
EOF
77+
78+
PLATFORM=''
79+
ARCH=$(uname -m)
80+
case $ARCH in
81+
'x86_64')
82+
PLATFORM='linux/amd64'
83+
;;
84+
'aarch64')
85+
PLATFORM='linux/arm64'
86+
;;
87+
esac
88+
89+
while [ $# -gt 0 ]; do
90+
case "$1" in
91+
--platform)
92+
PLATFORM="$2"
93+
;;
94+
--*)
95+
echo "Illegal option $1"
96+
;;
97+
esac
98+
shift $(($# > 0 ? 1 : 0))
99+
done
100+
101+
TIME=$(date -u '+%Y%m%dT%H%M%SZ')
102+
ARCH=$(uname -m)
103+
104+
TAG="alpine-3.20-v${VERSION}-${ARCH}-${TIME}"
105+
TAG=${VERSION}
106+
IMAGE="docker.io/phpswoole/swoole-cli:${TAG}"
107+
108+
#MIRROR='china'
109+
MIRROR=''
110+
docker buildx build -t ${IMAGE} -f ./Dockerfile . --platform ${PLATFORM} --build-arg="MIRROR=${MIRROR}"
111+
112+
echo ${IMAGE}
113+
114+
# docker save -o "swoole-cli-image.tar" ${IMAGE}
115+
: <<'EOF'
116+
{
117+
docker push ${IMAGE}
118+
} || {
119+
echo $?
120+
}
121+
EOF
122+
123+
docker run --rm --name demo ${IMAGE} swoole-cli -v
124+
docker run --rm --name demo ${IMAGE} swoole-cli -m
125+
docker run --rm --name demo ${IMAGE} swoole-cli -c /usr/local/swoole-cli/etc/php.ini --ri curl
126+
docker run --rm --name demo ${IMAGE} swoole-cli -c /usr/local/swoole-cli/etc/php.ini --ri openssl
127+
docker run --rm --name demo ${IMAGE} swoole-cli --ri swoole

sapi/scripts/cygwin/cygwin-config-ext.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fi
4949
mkdir -p ${WORK_TEMP_DIR}/ext/redis/
5050
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/redis/ -xf redis-${REDIS_VERSION}.tgz
5151

52-
: <<EOF
52+
: <<'EOF'
5353
# mongodb 扩展 不支持 cygwin 环境下构建
5454
# 详见: https://github.com/mongodb/mongo-php-driver/issues/1381
5555

sapi/scripts/cygwin/install-re2c.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ __PROJECT__=$(
1010
pwd
1111
)
1212
cd ${__PROJECT__}
13-
ROOT=${__PROJECT__}
14-
1513

1614
RE2C_VERSION=3.0
1715

18-
wget https://github.com/swoole/swoole-cli/releases/download/v5.0.1/re2c.exe
16+
curl -fSLo re2c.exe https://github.com/swoole/swoole-cli/releases/download/v5.0.1/re2c.exe
1917
mv ./re2c.exe /usr/bin/re2c
2018
chmod +x /usr/bin/re2c
2119
re2c -v
2220

2321
build_re2c() {
2422
cd /tmp
25-
wget https://github.com/skvadrik/re2c/releases/download/3.0/re2c-3.0.tar.xz
23+
curl -fSLo re2c-${RE2C_VERSION}.tar.xz https://github.com/skvadrik/re2c/releases/download/3.0/re2c-3.0.tar.xz
2624
tar xvf re2c-${RE2C_VERSION}.tar.xz
2725
cd re2c-${RE2C_VERSION}
2826
autoreconf -i -W all
2927
./configure --prefix=/usr && make -j $(nproc) && make install
30-
cd $ROOT
28+
cd ${__PROJECT__}
3129
}

sapi/src/UnitTest/scripts/database/my.cnf

-8
This file was deleted.

sapi/src/template/make.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
?>
99
#!/usr/bin/env bash
10+
shopt -s expand_aliases
1011
__PROJECT_DIR__=$(cd "$(dirname "$0")"; pwd)
1112
CLI_BUILD_TYPE=<?= $this->getBuildType() . PHP_EOL ?>
1213
SRC=<?= $this->phpSrcDir . PHP_EOL ?>
@@ -415,8 +416,8 @@
415416
if [ -n "$2" ]; then
416417
MIRROR=$2
417418
case "$MIRROR" in
418-
china | openatom )
419-
CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18"
419+
china | openatom)
420+
CONTAINER_BASE_IMAGE="docker.io/library/alpine:3.18"
420421
;;
421422
esac
422423
fi

setup-php-runtime.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ cd ${__PROJECT__}/
156156
set +x
157157

158158
echo " "
159-
echo " USE PHP RUNTIME :"
159+
echo " USE PHP RUNTIME : "
160160
echo " "
161161
echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" "
162162
echo " "
163+
echo " shopt -s expand_aliases "
164+
echo " "
163165
echo " alias php='php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' "
164166
echo " OR "
165167
echo " alias php='php -c ${__PROJECT__}/bin/runtime/php.ini' "

setup-swoole-cli-runtime.sh

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ echo " USE PHP-CLI RUNTIME :"
228228
echo " "
229229
echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" "
230230
echo " "
231+
echo " shopt -s expand_aliases "
232+
echo " "
231233
echo " alias swoole-cli='swoole-cli -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' "
232234
echo " OR "
233235
echo " alias swoole-cli='swoole-cli -c ${__PROJECT__}/bin/runtime/php.ini' "

0 commit comments

Comments
 (0)