Skip to content

Commit 08592a3

Browse files
committed
Add simple environment-based PHP configuration
This adds a layer of common sense on top of the other changes I've worked on to allow easy configuration variable setting. Fixes #166
1 parent 0a88c65 commit 08592a3

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ docker run \
7474

7575
These initialization files will be executed in sorted name order as defined by the current locale, which defaults to en_US.utf8.
7676

77+
## PHP Configuration
78+
79+
As a lightweight alternative to a full PHP configuration file, you can specify a set of prefixed environment variables when starting your container with these variables turned into ini-format configuration.
80+
81+
Any environment variable whose name is prefixed with `INI-` will have the prefix removed, and will be added to a new ini file before the main command starts.
82+
83+
```
84+
docker run \
85+
--name web0 \
86+
-p 8080:80 \
87+
-v $PWD/moodle:/var/www/html
88+
-e INI-upload_max_filesize=200M \
89+
-e INI-post_max_size=210M \
90+
moodle-php-apache:latest
91+
```
92+
7793
## See also
7894
This container is part of a set of containers for Moodle development, see also:
7995

root/usr/local/bin/moodle-docker-php-entrypoint

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ docker_process_init_files() {
2626
done
2727
}
2828

29+
echo "Running PHP Configuration fetcher"
30+
/usr/local/bin/moodle-docker-php-ini
31+
echo
32+
2933
echo "Running entrypoint files from /docker-entrypoint.d/*"
3034
docker_process_init_files /docker-entrypoint.d/*
3135
echo
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
echo "Checking for php configuration in environment"
6+
7+
localinifile="/usr/local/etc/php/conf.d/10-local.ini"
8+
9+
cat <<'EOF' > $localinifile
10+
; --
11+
; Automatically generated php ini configuration for Moodle
12+
; --
13+
14+
EOF
15+
16+
env | while IFS= read -r line; do
17+
value=${line#*=}
18+
fullname=${line%%=*}
19+
if [[ $fullname = INI-* ]]; then
20+
name=`echo $fullname | sed 's/^INI-//'`
21+
echo "=> Found '${name}' with value '${value}'"
22+
23+
cat << EOF >> $localinifile
24+
; $fullname=$value
25+
$name = $value
26+
27+
EOF
28+
fi
29+
done

0 commit comments

Comments
 (0)