Skip to content

Commit

Permalink
Build fpm and alpine.
Browse files Browse the repository at this point in the history
  • Loading branch information
pc-magas committed Dec 21, 2023
1 parent c9b197a commit 268011a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
3 changes: 3 additions & 0 deletions dockerfiles/fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ FROM php:${PHP_VERSION}-fpm as base
# Replace for later version

VOLUME ["/var/moodledata"]
VOLUME ["/var/www/html"]

EXPOSE 9000

# Let the container know that there is no tty
ENV DEBIAN_FRONTEND noninteractive \
Expand Down
86 changes: 46 additions & 40 deletions dockerfiles/fpm_alpine/Dockerfile
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

Expand All @@ -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\");" &&\
Expand All @@ -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/*

0 comments on commit 268011a

Please sign in to comment.