Skip to content

Commit 76ce09e

Browse files
committed
Minor changes
Reverted to Alpine 3.16.0 due to no PHP8 mods yet available for 3.17.0. Slight organization and stricter chmod. Stricter sed search and replace for httpd.conf.
1 parent a413c9c commit 76ce09e

2 files changed

Lines changed: 62 additions & 17 deletions

File tree

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
FROM alpine:3.17.0
1+
FROM alpine:3.16.0
22
LABEL maintainer="JulianPrieber"
33
LABEL description="LittleLink Custom Docker"
44

5+
EXPOSE 80 443
6+
57
# Setup apache and php
68
RUN apk --no-cache --update \
79
add apache2 \
@@ -28,20 +30,18 @@ RUN apk --no-cache --update \
2830
php8-pdo_sqlite \
2931
php8-phar \
3032
php8-session \
31-
tzdata \
3233
php8-xml \
3334
php8-tokenizer \
3435
php8-zip \
36+
tzdata \
3537
&& mkdir /htdocs
3638

3739
COPY littlelink-custom /htdocs
3840
RUN chown -R apache:apache /htdocs
3941
RUN find /htdocs -type d -print0 | xargs -0 chmod 0755
4042
RUN find /htdocs -type f -print0 | xargs -0 chmod 0644
4143

42-
EXPOSE 80 443
43-
44-
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/
44+
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/
4545

4646
HEALTHCHECK CMD curl -f http://localhost -A "HealthCheck" || exit 1
4747

docker-entrypoint.sh

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# Exit on non defined variables and on non zero exit codes
44
set -eu
55

6-
# Get/Set Variables
6+
# + ---------- + #
7+
# | -- VARS -- | #
8+
# + ---------- + #
9+
710
SERVER_ADMIN="${SERVER_ADMIN:-you@example.com}"
811
HTTP_SERVER_NAME="${HTTP_SERVER_NAME:-localhost}"
912
HTTPS_SERVER_NAME="${HTTPS_SERVER_NAME:-localhost}"
@@ -12,21 +15,37 @@ TZ="${TZ:-UTC}"
1215
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-256M}"
1316
UPLOAD_MAX_FILESIZE="${UPLOAD_MAX_FILESIZE:-8M}"
1417

15-
echo 'Updating Configuration: Apache Base (/etc/apache2/httpd.conf)'
18+
# If TRUE, outputs pre and post-change config files, if a /debug folder has also been mounted.
19+
# i.e. - '/opt/docker/configs/littlelink/debug:/debug:rw'
20+
# Useful for comparing (and fixing) changes, if necessary.
21+
DEBUG="TRUE"
22+
23+
echo '+ ------------------------------------------------------------------ +'
24+
echo '| LITTLELINK CUSTOM |'
25+
26+
# + ---------------- + #
27+
# | -- HTTPD.CONF -- | #
28+
# + ---------------- + #
29+
30+
echo '+ ------------------------------------------------------------------ +'
31+
echo '| Updating Configuration: Apache Base (/etc/apache2/httpd.conf) |'
32+
33+
# ALTER: Server Admin, Name, Document Root.
34+
35+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.BEFORE.conf;fi
1636

17-
# Change Server Admin, Name, Document Root
1837
sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/httpd.conf
1938
sed -i "s/#ServerName\ www.example.com:80/ServerName\ ${HTTP_SERVER_NAME}/" /etc/apache2/httpd.conf
2039
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/httpd.conf
2140
sed -i 's#Directory "/var/www/localhost/htdocs"#Directory "/htdocs"#g' /etc/apache2/httpd.conf
2241
sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf
2342

24-
# Change TransferLog after ErrorLog
43+
# ALTER: TransferLog after ErrorLog.
2544
sed -i 's#^ErrorLog .*#ErrorLog "logs/error.log"#g' /etc/apache2/httpd.conf
2645
sed -i 's#LogFormat .* %t#LogFormat "[%{%a %b %d %H:%M:%S}t.%{usec_frac}t %{%Y}t] [httpd.conf] %h %l %u#g' /etc/apache2/httpd.conf
27-
sed -i 's#CustomLog .* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
46+
sed -i 's#CustomLog logs.* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
2847

29-
# Re-define LogLevel
48+
# ALTER: LogLevel.
3049
sed -i "s#^LogLevel .*#LogLevel ${LOG_LEVEL}#g" /etc/apache2/httpd.conf
3150

3251
# Enable commonly used apache modules
@@ -35,9 +54,18 @@ sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/
3554
sed -i 's/#LoadModule\ logio_module/LoadModule\ logio_module/' /etc/apache2/httpd.conf
3655
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
3756

38-
echo 'Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf)'
57+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.AFTER.conf;fi
58+
59+
# + -------------- + #
60+
# | -- SSL.CONF -- | #
61+
# + -------------- + #
62+
63+
echo '| Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf) |'
64+
65+
# ALTER: SSL DocumentRoot and Log locations
66+
67+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.BEFORE.conf;fi
3968

40-
# SSL DocumentRoot and Log locations
4169
sed -i 's#^ErrorLog .*#ErrorLog "logs/ssl-error.log"#g' /etc/apache2/conf.d/ssl.conf
4270
sed -i "s/^TransferLog .*/#TransferLog \"logs\/ssl-transfer.log\"\nLogLevel ${LOG_LEVEL}/g" /etc/apache2/conf.d/ssl.conf
4371
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/conf.d/ssl.conf
@@ -47,16 +75,33 @@ sed -i "s/ServerName\ www.example.com:443/ServerName\ ${HTTPS_SERVER_NAME}/" /et
4775
sed -i 's#CustomLog .*#LogFormat "[%{%a %b %d %H:%M:%S}t.%{usec_frac}t %{%Y}t] [ssl.conf] %h %l %u \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined\n\nCustomLog "logs/ssl-access.log" combined#g' /etc/apache2/conf.d/ssl.conf
4876
sed -i '/.*%{SSL_PROTOCOL}x.*/d' /etc/apache2/conf.d/ssl.conf
4977

50-
echo 'Updating Configuration: PHP (/etc/php8/php.ini)'
78+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.AFTER.conf;fi
79+
80+
# + ------------- + #
81+
# | -- PHP.INI -- | #
82+
# + ------------- + #
83+
84+
echo '| Updating Configuration: PHP (/etc/php8/php.ini) |'
5185

52-
# Modify php memory limit and timezone
86+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.BEFORE.ini;fi
87+
88+
# ALTER: Modify php memory limit and timezone
5389
sed -i "s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/" /etc/php8/php.ini
5490
sed -i "s/upload_max_filesize = .*/upload_max_filesize = ${UPLOAD_MAX_FILESIZE}/" /etc/php8/php.ini
5591
sed -i "s#^;date.timezone =\$#date.timezone = \"${TZ}\"#" /etc/php8/php.ini
5692

5793
echo "is_llc_docker = true" >> /etc/php8/php.ini
5894

59-
echo 'Updating Configuration: Complete'
60-
echo 'Running Apache'
95+
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.AFTER.ini;fi
96+
97+
# + ---------- + #
98+
# | -- MISC -- | #
99+
# + ---------- + #
100+
101+
echo '| Updating Configuration: Complete |'
102+
echo '| ------------------------------------------------------------------ |'
103+
echo '| Running Apache |'
104+
echo '+ ------------------------------------------------------------------ +'
105+
echo
61106

62107
httpd -D FOREGROUND

0 commit comments

Comments
 (0)