Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/new_dev' into new_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jan 27, 2025
2 parents f05e0dc + 77824fc commit b72023a
Show file tree
Hide file tree
Showing 35 changed files with 548 additions and 79 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,16 @@ jobs:
bash ./make.sh all-library
bash ./make.sh config
# bash ./make.sh build
# bash ./make.sh archive
bash ./make.sh build
bash ./make.sh archive
- name: Start Database
run: |
# 准备数据库容器
export PATH=/usr/libexec/docker/cli-plugins/:$PATH
docker-compose version
docker container ls -a
bash sapi/docker/database/start.sh
- name: Show Build Result
run: |
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/push-to-gitee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: push to gitee

on:
push:
jobs:
push-to-gitee:
if: ${{ (github.repository_owner == 'jingjingxyk') && (github.repository == 'jingjingxyk/swoole-cli') }}
runs-on: ubuntu-latest
steps:
- name: install deps
run: |
sudo apt install openssh-client
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Prepare Secret Key
env:
PUSH_TO_GITEE_SECRET_KEY: ${{ secrets.PUSH_TO_GITEE_SECRET_KEY }}
run: |
mkdir -p ~/.ssh/
printf "%s\n" "$PUSH_TO_GITEE_SECRET_KEY" > ~/.ssh/swoole-cli-github-push-to-gitee-key
chmod 0400 ~/.ssh/swoole-cli-github-push-to-gitee-key
cat > ~/.ssh/config <<'EOF'
Host gitee.com
Hostname gitee.com
Port 22
PreferredAuthentications publickey
StrictHostKeyChecking no
IdentityFile ~/.ssh/swoole-cli-github-push-to-gitee-key
EOF
ls -lh ~/.ssh/
ssh -T [email protected]
- name: push to gitee
run: |
git remote add gitee [email protected]:jingjingxyk/swoole-cli.git
git remote -v
git push gitee --all
# git push gitee <branch name> --force
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ bash setup-php-runtime.sh
# 来自 https://www.swoole.com/download
bash setup-php-runtime.sh --mirror china

# 使用swoole-cli
# shell脚本中启用别名扩展功能‌
shopt -s expand_aliases
__DIR__=$(pwd)
export PATH="${__DIR__}/bin/runtime:$PATH"
ln -sf ${__DIR__}/bin/runtime/swoole-cli ${__DIR__}/bin/runtime/php
alias php="php -d curl.cainfo=${__DIR__}/bin/runtime/cacert.pem -d openssl.cafile=${__DIR__}/bin/runtime/cacert.pem"
which php
php -v

```

## 快速准备运行环境
Expand Down Expand Up @@ -143,6 +153,7 @@ php prepare.php -swoole +swoole_latest
# 编译最新版 swow
php prepare.php -swoole +swow_latest


```

* 脚本会自动下载相关的`C/C++`库以及`PECL`扩展
Expand Down
5 changes: 4 additions & 1 deletion build-release-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ if [ ! -f "${__PROJECT__}/bin/runtime/php" ]; then
fi

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

php -v
Expand Down Expand Up @@ -247,7 +250,7 @@ if [ ${IN_DOCKER} -eq 1 ]; then
{
# 容器中

php prepare.php +inotify ${OPTIONS}
php prepare.php ${OPTIONS}

}
else
Expand Down
2 changes: 1 addition & 1 deletion sapi/docker/build-export-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ done

case "$MIRROR" in
china | openatom)
CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18"
CONTAINER_BASE_IMAGE="docker.io/library/alpine:3.18"
;;
esac

Expand Down
18 changes: 14 additions & 4 deletions sapi/docker/database/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
version: "3"
services:
postgresql-server:
# image: postgres:15-alpine
image: postgis/postgis:15-3.3-alpine
image: postgres:17-alpine
# image: postgis/postgis:16-3.4-alpine
hostname: "postgresql"
container_name: "postgresql"
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=example"
# 容器内数据目录 /var/lib/postgresql/data
# auth_user: postgres
# auth_password: example
mysql-server:
# image: mysql:9
healthcheck:
test: [ "CMD-SHELL", "psql -U postgres -d postgres -c 'SELECT 1' || exit 1" ]
interval: 10s
timeout: 3s
retries: 3

mariadb-server:
image: mariadb:11
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --tls-version=''
environment:
Expand All @@ -26,11 +32,15 @@ services:
# 容器内数据目录 /var/lib/mysql
volumes:
- ./my.cnf:/etc/mysql/conf.d/my.cnf
healthcheck:
test: 'mysql --user=root --password=example --execute "SHOW DATABASES;"'

redis-server:
image: redis:7-alpine
ports:
- "6379:6379"
# 容器内数据目录 /data

mongodb-server:
image: mongo:latest
environment:
Expand Down
2 changes: 2 additions & 0 deletions sapi/docker/grafana/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ services:
- ./grafana-data:/var/lib/grafana

# 内置运行用户id: 472
# 账号 admin
# 密码 root


3 changes: 1 addition & 2 deletions sapi/docker/postgis/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: "3"
services:
postgresql-server:
# image: postgres:15-alpine
image: postgis/postgis:15-3.3-alpine
image: postgis/postgis:17-master
hostname: "postgis"
ports:
- "5432:5432"
Expand Down
19 changes: 19 additions & 0 deletions sapi/docker/postgresql/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"
services:
postgresql-server:
image: postgres:17-alpine
# image: postgis/postgis:16-3.4-alpine
hostname: "postgresql"
container_name: "postgresql"
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=example"
# 容器内数据目录 /var/lib/postgresql/data
# auth_user: postgres
# auth_password: example
healthcheck:
test: [ "CMD-SHELL", "psql -U postgres -d postgres -c 'SELECT 1' || exit 1" ]
interval: 10s
timeout: 3s
retries: 3
3 changes: 2 additions & 1 deletion sapi/docker/rabbitmq/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
rabbitmq-server:
image: rabbitmq:3-management-alpine
image: rabbitmq:4-management-alpine
container_name: rabbitmq
hostname: my-rabbit
restart: always
Expand All @@ -19,3 +19,4 @@ services:

# client library
# https://www.rabbitmq.com/client-libraries/devtools
# https://hub.docker.com/_/rabbitmq
5 changes: 3 additions & 2 deletions sapi/quickstart/linux/install-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ if [ ! -f /usr/libexec/docker/cli-plugins/docker-compose ]; then

# show more version info
# https://github.com/docker/compose/releases
VERSION="v2.32.1"
VERSION="v2.32.4"

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

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

else
export PATH=/usr/libexec/docker/cli-plugins/:$PATH
# export PATH=/usr/libexec/docker/cli-plugins/:$PATH
ln -sf /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
fi

docker-compose --version
2 changes: 1 addition & 1 deletion sapi/quickstart/linux/run-alpine-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while [ $# -gt 0 ]; do
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/alpine:3.18"
IMAGE="docker.io/library/alpine:3.18"
;;
esac
;;
Expand Down
2 changes: 1 addition & 1 deletion sapi/quickstart/linux/run-debian-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while [ $# -gt 0 ]; do
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/debian:12"
IMAGE="docker.io/library/debian:12"
;;
esac
;;
Expand Down
1 change: 1 addition & 0 deletions sapi/quickstart/windows/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写
[7zip](https://7-zip.org/)
[visualstudio](https://visualstudio.microsoft.com/zh-hans/downloads/)
[windows-sdk](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)
[远程桌面客户端](https://learn.microsoft.com/zh-cn/windows-server/remote/remote-desktop-services/clients/remote-desktop-clients)

## windows 软连接例子

Expand Down
127 changes: 127 additions & 0 deletions sapi/scripts/build-swoole-cli-alpine-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__PROJECT__=$(
cd ${__DIR__}/../../
pwd
)

cd ${__DIR__}
cd ${__PROJECT__}

test -d var/build-swoole-cli-container/ && rm -rf var/build-swoole-cli-container/
mkdir -p var/build-swoole-cli-container/
cd ${__PROJECT__}/var/build-swoole-cli-container/

cp -f ${__PROJECT__}/setup-swoole-cli-runtime.sh .

VERSION="6.0.0.0"
bash setup-swoole-cli-runtime.sh --version v${VERSION}

cat >php.ini <<'EOF'
curl.cainfo="/usr/local/swoole-cli/etc/cacert.pem"
openssl.cafile="/usr/local/swoole-cli/etc/cacert.pem"
swoole.use_shortname=off
display_errors = On
error_reporting = E_ALL
upload_max_filesize="128M"
post_max_size="128M"
memory_limit="1G"
date.timezone="UTC"
opcache.enable=On
opcache.enable_cli=On
opcache.jit=1225
opcache.jit_buffer_size=128M
; jit 更多配置参考 https://mp.weixin.qq.com/s/Tm-6XVGQSlz0vDENLB3ylA
expose_php=Off
apc.enable_cli=1
EOF

cat >Dockerfile <<'EOF'
FROM alpine:3.20
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN mkdir -p /usr/local/swoole-cli/etc/conf.d/
ADD ./bin/runtime/swoole-cli /usr/local/bin/
ADD ./bin/runtime/composer /usr/local/bin/
ADD ./bin/runtime/cacert.pem /usr/local/swoole-cli/etc/
ADD ./php.ini /usr/local/swoole-cli/etc/
RUN chmod a+x /usr/local/bin/swoole-cli
RUN chmod a+x /usr/local/bin/composer
RUN ln -sf /usr/local/bin/swoole-cli /usr/local/bin/php
ARG MIRROR=""
RUN test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
RUN if [ "${MIRROR}" = "ustc" -o "${MIRROR}" = "china" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; } fi
RUN if [ "${MIRROR}" = "tuna" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories ; } fi
RUN apk add ca-certificates tini bash
RUN mkdir /work
WORKDIR /work
ENTRYPOINT ["tini", "--"]
EOF

PLATFORM=''
ARCH=$(uname -m)
case $ARCH in
'x86_64')
PLATFORM='linux/amd64'
;;
'aarch64')
PLATFORM='linux/arm64'
;;
esac

while [ $# -gt 0 ]; do
case "$1" in
--platform)
PLATFORM="$2"
;;
--*)
echo "Illegal option $1"
;;
esac
shift $(($# > 0 ? 1 : 0))
done

TIME=$(date -u '+%Y%m%dT%H%M%SZ')
ARCH=$(uname -m)

TAG="alpine-3.20-v${VERSION}-${ARCH}-${TIME}"
TAG=${VERSION}
IMAGE="docker.io/phpswoole/swoole-cli:${TAG}"

#MIRROR='china'
MIRROR=''
docker buildx build -t ${IMAGE} -f ./Dockerfile . --platform ${PLATFORM} --build-arg="MIRROR=${MIRROR}"

echo ${IMAGE}

# docker save -o "swoole-cli-image.tar" ${IMAGE}
: <<'EOF'
{
docker push ${IMAGE}
} || {
echo $?
}
EOF

docker run --rm --name demo ${IMAGE} swoole-cli -v
docker run --rm --name demo ${IMAGE} swoole-cli -m
docker run --rm --name demo ${IMAGE} swoole-cli -c /usr/local/swoole-cli/etc/php.ini --ri curl
docker run --rm --name demo ${IMAGE} swoole-cli -c /usr/local/swoole-cli/etc/php.ini --ri openssl
docker run --rm --name demo ${IMAGE} swoole-cli --ri swoole
Loading

0 comments on commit b72023a

Please sign in to comment.