forked from jmhardison/docker-moodle
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# Dockerfile for moodle instance. | ||
#Original Maintainer Jon Auer <[email protected]> | ||
|
||
FROM php:7.4-fpm-alpine | ||
ARG PHP_VERSION="7.4" | ||
FROM php:${PHP_VERSION}-fpm-alpine as base | ||
|
||
# Replace for later version | ||
|
||
|
@@ -20,48 +21,14 @@ ENV \ | |
MOODLE_DB_NAME '' \ | ||
MOODLE_DB_PORT '3306' | ||
|
||
# Installing php and external tools | ||
# RUN \ | ||
# apk add --update curl bash rsync unzip netcat-openbsd libxml2-dev icu-dev libmcrypt-dev libpng-dev libjpeg-turbo-dev libzip-dev oniguruma-dev &&\ | ||
# docker-php-ext-install xmlrpc && \ | ||
# docker-php-ext-install mbstring && \ | ||
# docker-php-ext-configure zip && \ | ||
# docker-php-ext-install zip &&\ | ||
# docker-php-ext-install intl && \ | ||
# docker-php-ext-install soap && \ | ||
# docker-php-ext-install gd && \ | ||
# docker-php-ext-install opcache && \ | ||
# apk del unzip curl gcc g++ &&\ | ||
# rm -rf /var/cache/apk/* | ||
|
||
RUN echo "Build moodle version ${VERSION}" &&\ | ||
curl -sSLf \ | ||
-o /usr/local/bin/install-php-extensions \ | ||
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ | ||
chmod +x /usr/local/bin/install-php-extensions && \ | ||
|
||
RUN --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \ | ||
/usr/local/bin/install-php-extensions xmlrpc mbstring zip xml intl soap gd opcache &&\ | ||
rm -rf /usr/local/bin/install-php-extensions && \ | ||
echo "PHP_EXTENTION_DIR="$(php -i | grep extension_dir | cut -d " " -f 5) >> /etc/environment &&\ | ||
cat /etc/environment &&\ | ||
rm -rf /var/cache/apk/* | ||
|
||
ARG DB_TYPE="all" | ||
ENV MOODLE_DB_TYPE ${DB_TYPE} | ||
|
||
RUN \ | ||
if [[ $DB_TYPE = "mysqli" ]] || [[ $DB_TYPE = "all" ]]; then echo "Setup mysql and mariadb support" &&\ | ||
docker-php-ext-install pdo mysqli pdo_mysql;\ | ||
fi &&\ | ||
if [[ $DB_TYPE = "pgsql" ]] || [[ $DB_TYPE = "all" ]]; then echo "Setup postgresql support" &&\ | ||
apk add --update postgresql-dev &&\ | ||
docker-php-ext-install pdo pgsql pdo_pgsql;\ | ||
fi &&\ | ||
if [ $DB_TYPE = "mysqli" ] || [ $DB_TYPE = "pgsql" ]; then \ | ||
echo "SET DB_TYPE file" ;\ | ||
echo $DB_TYPE > /etc/db_type;\ | ||
fi &&\ | ||
rm -rf /var/cache/apk/* | ||
|
||
ARG VERSION=311 | ||
|
||
RUN \ | ||
echo "Installing moodle" && \ | ||
php -r "copy(\"https://packaging.moodle.org/stable${VERSION}/moodle-latest-${VERSION}.tgz\",\"/tmp/moodle-latest.tgz\");" &&\ | ||
|
@@ -80,4 +47,43 @@ RUN chown root:root /usr/local/bin/entrypoint.sh &&\ | |
chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["php-fpm"] | ||
CMD ["php-fpm"] | ||
|
||
FROM base as multibase | ||
|
||
ENV MOODLE_DB_TYPE 'all' | ||
|
||
RUN --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \ | ||
/usr/local/bin/install-php-extensions mysqli pdo_mysql pgsql pdo_pgsql &&\ | ||
php -i | grep extension_dir | cut -d " " -f 5 &&\ | ||
ls -l /usr/local/etc/php/conf.d/ &&\ | ||
apt-get autopurge -y &&\ | ||
apt-get autoremove -y &&\ | ||
apt-get autoclean &&\ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* cache/* /var/lib/log/* | ||
|
||
FROM base as mysql_maria | ||
|
||
ENV MOODLE_DB_TYPE 'mysqli' | ||
RUN echo 'mysqli' > /etc/db_type; | ||
|
||
# Use the argument CACHEBUST to disable caching during build bellow. This contains the build number. | ||
ARG CACHEBUST=0 | ||
RUN --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \ | ||
/usr/local/bin/install-php-extensions mysqli pdo_mysql &&\ | ||
php -i | grep extension_dir | cut -d " " -f 5 &&\ | ||
ls -l /usr/local/etc/php/conf.d/ &&\ | ||
rm -rf /var/cache/apk/* | ||
|
||
FROM base as postgres | ||
|
||
ENV MOODLE_DB_TYPE 'pgsql' | ||
RUN echo 'pgsql' > /etc/db_type; | ||
|
||
# Use the argument CACHEBUST to disable caching during build bellow. This contains the build number. | ||
ARG CACHEBUST=0 | ||
RUN --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \ | ||
/usr/local/bin/install-php-extensions pgsql pdo_pgsql &&\ | ||
php -i | grep extension_dir | cut -d " " -f 5 &&\ | ||
ls -l /usr/local/etc/php/conf.d/ &&\ | ||
rm -rf /var/cache/apk/* |