Skip to content

Add Swoole extension to container #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ COPY mods-available/sqlsrv.ini /etc/php/7.3/mods-available/sqlsrv.ini
COPY mods-available/sqlsrv.ini /etc/php/7.4/mods-available/sqlsrv.ini
COPY mods-available/sqlsrv.ini /etc/php/8.0/mods-available/sqlsrv.ini

# Install swoole modules for PHP 7.3 - 8.0
# (we don't need to support earlier than that in mezzio-swoole)
COPY mods-available/swoole.ini /etc/php/7.3/mods-available/swoole.ini
COPY mods-available/swoole.ini /etc/php/7.4/mods-available/swoole.ini
COPY mods-available/swoole.ini /etc/php/8.0/mods-available/swoole.ini
COPY scripts/install_swoole.sh /tmp/install_swoole.sh
RUN /tmp/install_swoole.sh && rm /tmp/install_swoole.sh

RUN mkdir -p /etc/laminas-ci/problem-matcher \
&& cd /etc/laminas-ci/problem-matcher \
&& wget https://raw.githubusercontent.com/shivammathur/setup-php/master/src/configs/phpunit.json \
Expand Down
21 changes: 18 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,31 @@ if [[ "${EXTENSIONS}" != "" ]];then
else
ENABLE_SQLSRV=true
fi
EXTENSIONS=$(echo ${EXTENSIONS} | sed -E -e 's/php[0-9.]+-(pdo[_-]){0,1}sqlsrv/ /g' | sed -E -e 's/\s{2,}/ /g')
EXTENSIONS=$(echo "${EXTENSIONS}" | sed -E -e 's/php[0-9.]+-(pdo[_-]){0,1}sqlsrv/ /g' | sed -E -e 's/\s{2,}/ /g')
fi

ENABLE_SWOOLE=false
if [[ "${EXTENSIONS}" =~ swoole ]];then
if [[ ! ${PHP} =~ (7.3|7.4|8.0) ]];then
echo "Skipping enabling of swoole extension; not supported on PHP < 7.3"
else
ENABLE_SWOOLE=true
fi
EXTENSIONS=$(echo "${EXTENSIONS}" | sed -E -e 's/php[0-9.]+-swoole/ /g' | sed -E -e 's/\s{2,}/ /g')
fi

echo "Installing extensions: ${EXTENSIONS}"
apt update
apt install -y ${EXTENSIONS}
apt install -y "${EXTENSIONS}"

if [[ "${ENABLE_SQLSRV}" == "true" ]];then
echo "Enabling sqlsrv extensions"
phpenmod -v ${PHP} -s ALL sqlsrv
phpenmod -v "${PHP}" -s ALL sqlsrv
fi

if [[ "${ENABLE_SWOOLE}" == "true" ]];then
echo "Enabling swoole extensions"
phpenmod -v "${PHP}" -s ALL swoole
fi
fi

Expand Down
3 changes: 3 additions & 0 deletions mods-available/swoole.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; configuration for php swoole module
; priority=20
extension=swoole.so
26 changes: 26 additions & 0 deletions scripts/install_swoole.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

SWOOLE_VERSION=4.6.7

# Get swoole package ONCE
cd /tmp
wget https://pecl.php.net/get/swoole-${SWOOLE_VERSION}.tgz
tar xzf swoole-${SWOOLE_VERSION}.tgz

# We only need to support currently supported PHP versions
for PHP_VERSION in 7.3 7.4 8.0;do
cd /tmp/swoole-${SWOOLE_VERSION}
if [ -f Makefile ];then
make clean
fi
phpize${PHP_VERSION}
./configure --enable-swoole --enable-sockets --with-php-config=php-config${PHP_VERSION}
make
make install
done

# Cleanup
rm -rf /tmp/swoole-${SWOOLE_VERSION}
rm /tmp/swoole-${SWOOLE_VERSION}.tgz