Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for docker-entrypoint.d #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
36 changes: 36 additions & 0 deletions root/usr/local/bin/moodle-docker-php-entrypoint
Original file line number Diff line number Diff line change
@@ -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