Skip to content

Commit 31956b1

Browse files
scarastronk7
authored andcommitted
Install solr extension from source
Using 2.4.0 release + custom patch (from macports project) seems to be the only working combination right now. Read the comments in the code and the links there. Resolves solr issue in moodlehq#16, waiting for the upstream as described in moodlehq#19 This is basically a backport of moodlehq#58 that was applied to php72 and up. The problem with php71 was detected @ moodlehq/moodle-docker#134 (comment)
1 parent 47a3769 commit 31956b1

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

root/tmp/setup/php-extensions.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ docker-php-ext-install -j$(nproc) gd
5858
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/
5959
docker-php-ext-install -j$(nproc) ldap
6060

61-
# SOLR, Memcached, Redis, APCu, igbinary.
62-
pecl install solr memcached mongodb redis apcu igbinary uuid
63-
docker-php-ext-enable solr memcached mongodb redis apcu igbinary uuid
61+
# Memcached, MongoDB, Redis, APCu, igbinary.
62+
pecl install memcached mongodb redis apcu igbinary uuid
63+
docker-php-ext-enable memcached mongodb redis apcu igbinary uuid
6464

6565
echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
6666

@@ -73,6 +73,19 @@ ACCEPT_EULA=Y apt-get install -y msodbcsql17
7373
pecl install sqlsrv-5.6.1
7474
docker-php-ext-enable sqlsrv
7575

76+
# Install custom solr extension. Last release (2.4.0) is not working at all
77+
# with php72 and php73 and upstream has not either! Solution:
78+
# - current master (as of 21th May 2019):
79+
# https://github.com/php/pecl-search_engine-solr/commit/98a8bf540bcb4e9b2e1378cce2f3a9bf6cd772b8
80+
# - this patch, applied already upstream:
81+
# https://github.com/php/pecl-search_engine-solr/commit/744e32915d5989101267ed2c84a407c582dc6f31
82+
# So, following the experience with Macports, and https://bugs.php.net/bug.php?id=75631
83+
# we are going to try 2.4.0 release + macports patch. Old, but working right now.
84+
# References:
85+
# - https://github.com/moodlehq/moodle-php-apache/issues/16 (part of the php72 image discussion)
86+
# - https://github.com/moodlehq/moodle-php-apache/issues/19 (awaiting for a better solution)
87+
/tmp/setup/solr-extension.sh
88+
7689
# Keep our image size down..
7790
pecl clear-cache
7891
apt-get remove --purge -y $BUILD_PACKAGES

root/tmp/setup/solr-extension.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Install 2.4.0 release version + macports patch. Only combination working right now.
6+
# See #16 and #19 for more information.
7+
hash=6e9e097c981e810d452657f23bf1945b7955f3cf
8+
patch=https://raw.githubusercontent.com/macports/macports-ports/master/php/php-solr/files/php72.patch
9+
10+
# Download our 'tagged' source code from git.
11+
echo "Downloading solr extension source archive (${hash})"
12+
curl --location \
13+
https://github.com/php/pecl-search_engine-solr/archive/${hash}.tar.gz \
14+
-o /tmp/pecl-search_engine-solr-${hash}.tar.gz
15+
16+
# Download patch
17+
if [ -n $patch ]; then
18+
curl --location \
19+
$patch \
20+
-o /tmp/solr.patch
21+
fi
22+
23+
# Extract the compressed archive.
24+
cd /tmp
25+
tar -xvzf pecl-search_engine-solr-${hash}.tar.gz
26+
cd pecl-search_engine-solr-${hash}
27+
28+
# Apply the patch
29+
if [ -n $patch ]; then
30+
patch -p0 < ../solr.patch
31+
fi
32+
33+
# Compile the extension as required by a manual PECL installation.
34+
echo "Compile solr extension"
35+
phpize
36+
./configure
37+
make
38+
39+
# Finally, install it.
40+
echo "Install solr extension"
41+
make install
42+
43+
# Remove all the sources.
44+
echo "Cleanup temporary folder and files"
45+
rm /tmp/pecl-search_engine-solr-${hash} -rf
46+
rm /tmp/pecl-search_engine-solr-${hash}.tar.gz -f
47+
rm /tmp/solr.patch -f
48+
49+
# Enable it.
50+
docker-php-ext-enable solr
51+
52+
# Done with this hack.
53+
# Please, follow https://github.com/moodlehq/moodle-php-apache/issues/19.

0 commit comments

Comments
 (0)