Skip to content

Commit 37e8bb0

Browse files
Merge pull request #40 from weierophinney/feature/swoole-extension
Add Swoole extension to container
2 parents 6437fd6 + ab0d132 commit 37e8bb0

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ COPY mods-available/sqlsrv.ini /etc/php/7.3/mods-available/sqlsrv.ini
140140
COPY mods-available/sqlsrv.ini /etc/php/7.4/mods-available/sqlsrv.ini
141141
COPY mods-available/sqlsrv.ini /etc/php/8.0/mods-available/sqlsrv.ini
142142

143+
# Install swoole modules for PHP 7.3 - 8.0
144+
# (we don't need to support earlier than that in mezzio-swoole)
145+
COPY mods-available/swoole.ini /etc/php/7.3/mods-available/swoole.ini
146+
COPY mods-available/swoole.ini /etc/php/7.4/mods-available/swoole.ini
147+
COPY mods-available/swoole.ini /etc/php/8.0/mods-available/swoole.ini
148+
COPY scripts/install_swoole.sh /tmp/install_swoole.sh
149+
RUN /tmp/install_swoole.sh && rm /tmp/install_swoole.sh
150+
143151
RUN mkdir -p /etc/laminas-ci/problem-matcher \
144152
&& cd /etc/laminas-ci/problem-matcher \
145153
&& wget https://raw.githubusercontent.com/shivammathur/setup-php/master/src/configs/phpunit.json \

entrypoint.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,31 @@ if [[ "${EXTENSIONS}" != "" ]];then
156156
else
157157
ENABLE_SQLSRV=true
158158
fi
159-
EXTENSIONS=$(echo ${EXTENSIONS} | sed -E -e 's/php[0-9.]+-(pdo[_-]){0,1}sqlsrv/ /g' | sed -E -e 's/\s{2,}/ /g')
159+
EXTENSIONS=$(echo "${EXTENSIONS}" | sed -E -e 's/php[0-9.]+-(pdo[_-]){0,1}sqlsrv/ /g' | sed -E -e 's/\s{2,}/ /g')
160+
fi
161+
162+
ENABLE_SWOOLE=false
163+
if [[ "${EXTENSIONS}" =~ swoole ]];then
164+
if [[ ! ${PHP} =~ (7.3|7.4|8.0) ]];then
165+
echo "Skipping enabling of swoole extension; not supported on PHP < 7.3"
166+
else
167+
ENABLE_SWOOLE=true
168+
fi
169+
EXTENSIONS=$(echo "${EXTENSIONS}" | sed -E -e 's/php[0-9.]+-swoole/ /g' | sed -E -e 's/\s{2,}/ /g')
160170
fi
161171

162172
echo "Installing extensions: ${EXTENSIONS}"
163173
apt update
164-
apt install -y ${EXTENSIONS}
174+
apt install -y "${EXTENSIONS}"
165175

166176
if [[ "${ENABLE_SQLSRV}" == "true" ]];then
167177
echo "Enabling sqlsrv extensions"
168-
phpenmod -v ${PHP} -s ALL sqlsrv
178+
phpenmod -v "${PHP}" -s ALL sqlsrv
179+
fi
180+
181+
if [[ "${ENABLE_SWOOLE}" == "true" ]];then
182+
echo "Enabling swoole extensions"
183+
phpenmod -v "${PHP}" -s ALL swoole
169184
fi
170185
fi
171186

mods-available/swoole.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; configuration for php swoole module
2+
; priority=20
3+
extension=swoole.so

scripts/install_swoole.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SWOOLE_VERSION=4.6.7
6+
7+
# Get swoole package ONCE
8+
cd /tmp
9+
wget https://pecl.php.net/get/swoole-${SWOOLE_VERSION}.tgz
10+
tar xzf swoole-${SWOOLE_VERSION}.tgz
11+
12+
# We only need to support currently supported PHP versions
13+
for PHP_VERSION in 7.3 7.4 8.0;do
14+
cd /tmp/swoole-${SWOOLE_VERSION}
15+
if [ -f Makefile ];then
16+
make clean
17+
fi
18+
phpize${PHP_VERSION}
19+
./configure --enable-swoole --enable-sockets --with-php-config=php-config${PHP_VERSION}
20+
make
21+
make install
22+
done
23+
24+
# Cleanup
25+
rm -rf /tmp/swoole-${SWOOLE_VERSION}
26+
rm /tmp/swoole-${SWOOLE_VERSION}.tgz

0 commit comments

Comments
 (0)