Skip to content

Commit

Permalink
支持php8和swoole 5
Browse files Browse the repository at this point in the history
  • Loading branch information
李小培 committed Nov 30, 2022
1 parent f2c8e68 commit c50b5ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 112 deletions.
111 changes: 6 additions & 105 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,112 +1,13 @@
FROM alpine:3.9
# FROM phpswoole/swoole:4.8-php7.4-alpine
FROM phpswoole/swoole:latest

LABEL maintainer="Swoole Jobs <[email protected]>" version="1.0" license="MIT"
LABEL maintainer="Swoole Jobs <[email protected]>" version="1.1" license="MIT"

##
# ---------- building ----------
##
RUN set -ex \
# change apk source repo
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
&& apk update \
&& apk add --no-cache \
# Install base packages ('ca-certificates' will install 'nghttp2-libs')
ca-certificates \
curl \
wget \
tar \
xz \
libressl \
tzdata \
pcre \
php7 \
php7-pecl-amqp \
php7-bcmath \
php7-curl \
php7-ctype \
php7-dom \
php7-fileinfo \
php7-gd \
php7-iconv \
php7-json \
php7-mbstring \
php7-mysqlnd \
php7-openssl \
php7-pdo \
php7-pdo_mysql \
php7-pdo_sqlite \
php7-phar \
php7-posix \
php7-redis \
php7-simplexml \
php7-sockets \
php7-sodium \
php7-sysvshm \
php7-sysvmsg \
php7-sysvsem \
php7-tokenizer \
php7-zip \
php7-zlib \
php7-xml \
php7-xmlreader \
php7-xmlwriter \
php7-pcntl \
&& apk del --purge *-dev \
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php7 \
&& php -v \
&& php -m


ARG swoole
RUN docker-php-ext-install amqp

##
# ---------- env settings ----------
##
ENV SWOOLE_VERSION=${swoole:-"4.4.3"} \
# install and remove building packages
PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc libc-dev make php7-dev php7-pear pkgconf re2c pcre-dev zlib-dev libtool automake"

# update
RUN set -ex \
&& apk update \
# for swoole extension libaio linux-headers
&& apk add --no-cache libstdc++ openssl git bash \
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev \
# download
&& cd /tmp \
&& curl -SL "https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz" -o swoole.tar.gz \
&& ls -alh \
# php extension:swoole
&& cd /tmp \
&& mkdir -p swoole \
&& tar -xf swoole.tar.gz -C swoole --strip-components=1 \
&& ( \
cd swoole \
&& phpize \
&& ./configure --enable-mysqlnd --enable-openssl \
&& make -s -j$(nproc) && make install \
) \
&& printf "extension=swoole.so\n\
swoole.use_shortname = 'Off'\n\
swoole.enable_coroutine = 'Off'\n\
" >/etc/php7/conf.d/swoole.ini \
# clear
&& php -v \
&& php -m \
&& php --ri swoole \
# ---------- clear works ----------
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man

RUN printf "# composer php cli ini settings\n\
RUN printf "# php cli ini settings\n\
date.timezone=PRC\n\
memory_limit=-1\n\
" > /etc/php7/php.ini
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp
ENV COMPOSER_VERSION 1.9.0

RUN curl -SL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o composer.phar \
&& mv composer.phar /usr/bin/composer \
&& chmod u+x /usr/bin/composer \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
" >> /usr/local/etc/php/conf.d/php.ini
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"homepage": "https://github.com/kcloze/swoole-jobs",
"license": "MIT",
"require": {
"php": ">=7.0",
"ext-swoole": ">=1.8.9",
"php": ">=8.0",
"ext-swoole": ">=4.8",
"ext-redis": "*",
"symfony/console": "^3.4",
"bramus/router": "^1.3",
"guzzlehttp/guzzle": "^6.3",
"enqueue/amqp-ext": "^0.8"
"symfony/console": "^6.1",
"bramus/router": "^1.6",
"guzzlehttp/guzzle": "^7.5"

},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7"
Expand Down
1 change: 1 addition & 0 deletions src/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->printHelpMessage();
break;
}
return 0;
}

abstract protected function start();
Expand Down
2 changes: 1 addition & 1 deletion src/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function reserveQueue($num, $topic, $type=self::CHILD_PROCESS_CAN_RESTART
unset($num, $topic, $type);
});

$this->disableCoroutine($reserveProcess);
//$this->disableCoroutine($reserveProcess);

$pid = $reserveProcess->start();
$this->workers[$pid] = $reserveProcess;
Expand Down

0 comments on commit c50b5ea

Please sign in to comment.