From f38c20a7b0a65e90fe66ab08b4386c98d7b175d6 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 19 Apr 2023 14:31:10 +0800 Subject: [PATCH] Add support for docker-entrypoint.d This will allow us to more easily use a docker image hosted over https. --- Dockerfile | 32 ++++++++++++++++- .../local/bin/moodle-docker-php-entrypoint | 36 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 root/usr/local/bin/moodle-docker-php-entrypoint diff --git a/Dockerfile b/Dockerfile index f9c99d0..0192fdd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,35 @@ FROM php:7.1-apache -COPY . /var/www/html HEALTHCHECK --interval=5s CMD curl -f http://localhost:$(cat /etc/apache2/ports.conf | grep '^Listen' | cut -d ' ' -f 2) || exit 1 + +# Unfortunately this repository is used in other places and not simple to restructure. +# All files are in the root at the moment. +COPY H5P.Accordion.h5p /var/www/html +COPY behat-rsstest.xml /var/www/html +COPY downloadtests.md5 /var/www/html +COPY downloadtests.zip /var/www/html +COPY h5pcontenttypes.json /var/www/html +COPY h5puuid.json /var/www/html +COPY ical.ics /var/www/html +COPY ims_cartridge_basic_lti_link.xml /var/www/html +COPY index.html /var/www/html +COPY lti_keyset.json /var/www/html +COPY rss_redir.php /var/www/html +COPY rsstest.xml /var/www/html +COPY test.html /var/www/html +COPY test.jpg /var/www/html +COPY test_agent.php /var/www/html +COPY test_file.php /var/www/html +COPY test_file_name.php /var/www/html +COPY test_post.php /var/www/html +COPY test_redir.php /var/www/html +COPY test_redir_proto.php /var/www/html +COPY test_relative_redir.php /var/www/html +COPY testnodtd.html /var/www/html + +# Create the entrypoint. +COPY root/usr /usr + +CMD ["apache2-foreground"] +ENTRYPOINT ["moodle-docker-php-entrypoint"] diff --git a/root/usr/local/bin/moodle-docker-php-entrypoint b/root/usr/local/bin/moodle-docker-php-entrypoint new file mode 100755 index 0000000..3abc465 --- /dev/null +++ b/root/usr/local/bin/moodle-docker-php-entrypoint @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -Eeo pipefail + +docker_process_init_files() { + local f + for f; do + case "$f" in + *.sh) + # Note: This hack is required for MacOS because the exeute bit is not checked for bind mounts. + # The executable bit is stored, but the test -x flag does not return corretly. + # Copying the file to an alternate file system allows it to be respected. + rm -f /tmp/testscript + cp "$f" /tmp/testscript + if [ -x "/tmp/testscript" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; + *.ini) + echo "$0: copying $f into /usr/local/etc/php/conf.d/" + cp "$f" /usr/local/etc/php/conf.d/ + ;; + esac + done +} + +echo "Running entrypoint files from /docker-entrypoint.d/*" +docker_process_init_files /docker-entrypoint.d/* +echo + +echo "Starting docker-php-entrypoint with $@" +source /usr/local/bin/docker-php-entrypoint +echo