Skip to content

Commit fdd388c

Browse files
committed
8.0-bullseye
1 parent 146e1fb commit fdd388c

File tree

12 files changed

+374
-0
lines changed

12 files changed

+374
-0
lines changed

8.0/bullseye/Dockerfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM php:8.0-apache-bullseye
2+
3+
# So we can use it anywhere for conditional stuff. Keeping BC with old (non-buildkit, builders)
4+
ARG TARGETPLATFORM
5+
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
6+
RUN echo "Building for ${TARGETPLATFORM}"
7+
8+
# Install some packages that are useful within the images.
9+
RUN apt-get update && apt-get install -y \
10+
git \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Install pickle as an easier alternative to PECL, that is not
14+
# available any more for PHP 8 and up. Some alternatives searched were:
15+
# - https://olvlvl.com/2019-06-docker-pecl-without-pecl
16+
# - https://github.com/FriendsOfPHP/pickle
17+
# - manually "curl https://pecl.php.net/get/xxxx && tar && docker-php-ext-install xxx"
18+
# Of course, if the images end using some alternative, we'll switch to it. Just right now
19+
# there isn't such an alternative.a
20+
#
21+
# Update 20201126: Finally, see https://github.com/docker-library/php/issues/1087 it seems that pear/pecl
22+
# continues being availbale with php8, so we are going to continue using it. The previous comments as
23+
# left in case we need to find an alternative way to install PECL stuff and there isn't any official.
24+
# For an example of php80-rc5 near complete, using pickle instead of pear/pecl, look to:
25+
# https://github.com/stronk7/moodle-php-apache/tree/8.0-buster-pickle-version
26+
27+
# Setup the required extensions.
28+
ARG DEBIAN_FRONTEND=noninteractive
29+
ADD root/tmp/setup/php-extensions.sh /tmp/setup/php-extensions.sh
30+
RUN /tmp/setup/php-extensions.sh
31+
32+
# Install Oracle Instantclient
33+
ADD root/tmp/setup/oci8-extension.sh /tmp/setup/oci8-extension.sh
34+
RUN /tmp/setup/oci8-extension.sh
35+
ENV LD_LIBRARY_PATH /usr/local/instantclient
36+
37+
# Install Microsoft sqlsrv.
38+
ADD root/tmp/setup/sqlsrv-extension.sh /tmp/setup/sqlsrv-extension.sh
39+
RUN /tmp/setup/sqlsrv-extension.sh
40+
41+
RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
42+
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
43+
mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \
44+
mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps
45+
46+
ADD root/usr /usr
47+
48+
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
49+
RUN chmod 777 /tmp && chmod +t /tmp
50+
51+
CMD ["apache2-foreground"]
52+
ENTRYPOINT ["moodle-docker-php-entrypoint"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [[ ${TARGETPLATFORM} != "linux/amd64" ]]; then
6+
echo "oracle extension not available for ${TARGETPLATFORM} architecture, skipping"
7+
exit 0
8+
fi
9+
10+
echo "Downloading oracle files"
11+
curl https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip \
12+
-o /tmp/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip
13+
curl https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip \
14+
-o /tmp/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip
15+
curl https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip \
16+
-o /tmp/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip
17+
18+
unzip /tmp/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip -d /usr/local/
19+
rm /tmp/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip
20+
unzip /tmp/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip -d /usr/local/
21+
rm /tmp/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip
22+
unzip /tmp/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip -d /usr/local/
23+
rm /tmp/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip
24+
25+
ln -s /usr/local/instantclient_21_6 /usr/local/instantclient
26+
ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus
27+
28+
echo 'instantclient,/usr/local/instantclient' | pecl install oci8-3.0.1
29+
docker-php-ext-enable oci8
30+
echo 'oci8.statement_cache_size = 0' >> /usr/local/etc/php/conf.d/docker-php-ext-oci8.ini
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
echo "Installing apt dependencies"
6+
7+
# Build packages will be added during the build, but will be removed at the end.
8+
BUILD_PACKAGES="gettext libcurl4-openssl-dev libfreetype6-dev libicu-dev libjpeg62-turbo-dev \
9+
libldap2-dev libmariadb-dev libmemcached-dev libpng-dev libpq-dev libxml2-dev libxslt-dev \
10+
uuid-dev"
11+
12+
# Packages for Postgres.
13+
PACKAGES_POSTGRES="libpq5"
14+
15+
# Packages for MariaDB and MySQL.
16+
PACKAGES_MYMARIA="libmariadb3"
17+
18+
# Packages for other Moodle runtime dependenices.
19+
PACKAGES_RUNTIME="ghostscript libaio1 libcurl4 libgss3 libicu67 libmcrypt-dev libxml2 libxslt1.1 \
20+
libzip-dev locales sassc unzip zip"
21+
22+
# Packages for Memcached.
23+
PACKAGES_MEMCACHED="libmemcached11 libmemcachedutil2"
24+
25+
# Packages for LDAP.
26+
PACKAGES_LDAP="libldap-2.4-2"
27+
28+
apt-get update
29+
apt-get install -y --no-install-recommends apt-transport-https \
30+
$BUILD_PACKAGES \
31+
$PACKAGES_POSTGRES \
32+
$PACKAGES_MYMARIA \
33+
$PACKAGES_RUNTIME \
34+
$PACKAGES_MEMCACHED \
35+
$PACKAGES_LDAP
36+
37+
# Generate the locales configuration fo rboth Australia, and the US.
38+
echo 'Generating locales..'
39+
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
40+
echo 'en_AU.UTF-8 UTF-8' >> /etc/locale.gen
41+
locale-gen
42+
43+
echo "Installing php extensions"
44+
45+
# ZIP
46+
docker-php-ext-configure zip --with-zip
47+
docker-php-ext-install zip
48+
49+
docker-php-ext-install -j$(nproc) \
50+
exif \
51+
intl \
52+
mysqli \
53+
opcache \
54+
pgsql \
55+
soap \
56+
xsl
57+
58+
# GD.
59+
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
60+
docker-php-ext-install -j$(nproc) gd
61+
62+
# LDAP.
63+
docker-php-ext-configure ldap
64+
docker-php-ext-install -j$(nproc) ldap
65+
66+
# APCu, igbinary, Memcached, MongoDB, PCov, Redis, Solr, timezonedb, uuid, XMLRPC (beta)
67+
pecl install apcu igbinary memcached mongodb pcov redis solr timezonedb uuid xmlrpc-beta
68+
docker-php-ext-enable apcu igbinary memcached mongodb pcov redis solr timezonedb uuid xmlrpc
69+
70+
echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
71+
72+
echo "pcov.enabled=0" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
73+
echo "pcov.exclude='~\/(tests|coverage|vendor|node_modules)\/~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
74+
echo "pcov.directory=." >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
75+
echo "pcov.initial.files=1024" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
76+
77+
# Keep our image size down..
78+
pecl clear-cache
79+
apt-get remove --purge -y $BUILD_PACKAGES
80+
apt-get autoremove -y
81+
apt-get clean
82+
rm -rf /var/lib/apt/lists/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [[ ${TARGETPLATFORM} != "linux/amd64" ]]; then
6+
echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping"
7+
exit 0
8+
fi
9+
10+
# Packages for build.
11+
BUILD_PACKAGES="gnupg unixodbc-dev"
12+
13+
# Packages for sqlsrv runtime.
14+
PACKAGES_SQLSRV="unixodbc"
15+
16+
# Note: These dependencies must be installed before installing the Microsoft source because there is a package in there
17+
# which breaks the install.
18+
echo "Installing apt dependencies"
19+
apt-get update
20+
apt-get install -y --no-install-recommends apt-transport-https \
21+
$BUILD_PACKAGES \
22+
$PACKAGES_SQLSRV
23+
24+
# Install Microsoft dependencies for sqlsrv
25+
echo "Downloading sqlsrv files"
26+
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
27+
# TODO, bullseye should be 11, but the msodbcsql17 package is not available yet, hence using buster (10) one.
28+
curl https://packages.microsoft.com/config/debian/10/prod.list -o /etc/apt/sources.list.d/mssql-release.list
29+
apt-get update
30+
31+
echo "Install msodbcsql"
32+
ACCEPT_EULA=Y apt-get install -y msodbcsql17
33+
34+
ln -fsv /opt/mssql-tools/bin/* /usr/bin
35+
36+
# Need 5.9.0preview1 (or later) for PHP 8.0 support
37+
pecl install sqlsrv-5.10.0
38+
docker-php-ext-enable sqlsrv
39+
40+
# Keep our image size down..
41+
pecl clear-cache
42+
apt-get remove --purge -y $BUILD_PACKAGES
43+
apt-get autoremove -y
44+
apt-get clean
45+
rm -rf /var/lib/apt/lists/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -Eeo pipefail
3+
4+
docker_process_init_files() {
5+
local f
6+
for f; do
7+
case "$f" in
8+
*.sh)
9+
# Note: This hack is required for MacOS because the exeute bit is not checked for bind mounts.
10+
# The executable bit is stored, but the test -x flag does not return corretly.
11+
# Copying the file to an alternate file system allows it to be respected.
12+
rm -f /tmp/testscript
13+
cp "$f" /tmp/testscript
14+
if [ -x "/tmp/testscript" ]; then
15+
echo "$0: running $f"
16+
"$f"
17+
else
18+
echo "$0: sourcing $f"
19+
. "$f"
20+
fi
21+
;;
22+
*.ini)
23+
echo "$0: copying $f into /usr/local/etc/php/conf.d/"
24+
cp "$f" /usr/local/etc/php/conf.d/
25+
;;
26+
esac
27+
done
28+
}
29+
30+
echo "Running entrypoint files from /docker-entrypoint.d/*"
31+
docker_process_init_files /docker-entrypoint.d/*
32+
echo
33+
34+
echo "Starting docker-php-entrypoint with $@"
35+
source /usr/local/bin/docker-php-entrypoint
36+
echo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; CONFIGURATION SETTINGS REQUIRED BY MOODLE
2+
3+
; How many GET/POST/COOKIE input variables may be accepted
4+
; See MDL-71390 for more info. This is the recommended / required
5+
; value to support sites having 1000 courses, activities, users....
6+
max_input_vars = 5000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; Test file which disable file uploads.
2+
file_uploads = Off
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file should not have a shbang! as it is expected to be sourced.
2+
# It should not be executable either.
3+
4+
mkdir -p /var/www/data
5+
6+
(return 0 2>/dev/null) && sourced=1 || sourced=0
7+
8+
if [[ $sourced -eq 1 ]]; then
9+
echo "Sourced" >> /var/www/data/sourced.txt
10+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file should not have a shbang! as it is expected to be sourced.
2+
# It should not be executable either.
3+
4+
mkdir -p /var/www/data
5+
6+
(return 0 2>/dev/null) && sourced=1 || sourced=0
7+
8+
if [[ $sourced -eq 0 ]]; then
9+
echo "Executed" >> /var/www/data/executed.txt
10+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
$sourced = file_exists('/var/www/data/sourced.txt');
4+
$executed = file_exists('/var/www/data/executed.txt');
5+
6+
if (php_sapi_name() === 'cli') {
7+
if ($sourced && $executed) {
8+
echo "OK\n";
9+
exit(0);
10+
} else if ($sourced && !$executed) {
11+
echo "Executable file was not executed";
12+
} else {
13+
echo "non-executable file was not sourced";
14+
}
15+
exit(1);
16+
} else {
17+
if ($sourced && $executed) {
18+
header('HTTP/1.1 200 - OK');
19+
exit(0);
20+
} else if ($sourced && !$executed) {
21+
$message = "Executable file was not executed";
22+
} else {
23+
$message = "non-executable file was not sourced";
24+
}
25+
header('HTTP/1.1 500 - ' . $message);
26+
exit(1);
27+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
$uploadsEnabled = ini_get('file_uploads');
4+
5+
if (php_sapi_name() === 'cli') {
6+
if (empty($uploadsEnabled)) {
7+
echo "OK\n";
8+
exit(0);
9+
}
10+
echo "Uploads are enabled and should be disabled.";
11+
var_dump($uploadsEnabled);
12+
exit(1);
13+
} else {
14+
if (empty($uploadsEnabled)) {
15+
header('HTTP/1.1 200 - OK');
16+
exit(0);
17+
}
18+
header('HTTP/1.1 500 - Uploads are enabled and should be disabled: ' . var_export($uploadsEnabled, true));
19+
exit(1);
20+
}

8.0/bullseye/tests/fixtures/test.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
$requiredextensions = [
4+
'apcu',
5+
'exif',
6+
'gd',
7+
'igbinary',
8+
'intl',
9+
'ldap',
10+
'memcached',
11+
'mongodb',
12+
'mysqli',
13+
'oci8',
14+
'pgsql',
15+
'redis',
16+
'soap',
17+
'sodium',
18+
'solr',
19+
'sqlsrv',
20+
'uuid',
21+
'xsl',
22+
'xmlrpc',
23+
'zip',
24+
];
25+
26+
$buffer = '';;
27+
$missing = [];
28+
foreach($requiredextensions as $ext) {
29+
if (!extension_loaded($ext)) {
30+
$missing[] = $ext;
31+
}
32+
}
33+
34+
$locale = 'en_AU.UTF-8';
35+
if (setlocale(LC_TIME, $locale) === false) {
36+
$missing[] = $locale;
37+
}
38+
39+
if (php_sapi_name() === 'cli') {
40+
if (empty($missing)) {
41+
echo "OK\n";
42+
exit(0);
43+
}
44+
echo 'Missing: '.join(', ', $missing)."\n";
45+
exit(1);
46+
} else {
47+
if (empty($missing)) {
48+
header('HTTP/1.1 200 - OK');
49+
exit(0);
50+
} else {
51+
header('HTTP/1.1 500 - Problem PHP extension missing: ' . join(', ', $missing));
52+
exit(1);
53+
}
54+
}

0 commit comments

Comments
 (0)