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.
This commit is contained in:
parent
a413c9c632
commit
76ce09e1f0
10
Dockerfile
10
Dockerfile
|
@ -1,7 +1,9 @@
|
|||
FROM alpine:3.17.0
|
||||
FROM alpine:3.16.0
|
||||
LABEL maintainer="JulianPrieber"
|
||||
LABEL description="LittleLink Custom Docker"
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
# Setup apache and php
|
||||
RUN apk --no-cache --update \
|
||||
add apache2 \
|
||||
|
@ -28,10 +30,10 @@ RUN apk --no-cache --update \
|
|||
php8-pdo_sqlite \
|
||||
php8-phar \
|
||||
php8-session \
|
||||
tzdata \
|
||||
php8-xml \
|
||||
php8-tokenizer \
|
||||
php8-zip \
|
||||
tzdata \
|
||||
&& mkdir /htdocs
|
||||
|
||||
COPY littlelink-custom /htdocs
|
||||
|
@ -39,9 +41,7 @@ RUN chown -R apache:apache /htdocs
|
|||
RUN find /htdocs -type d -print0 | xargs -0 chmod 0755
|
||||
RUN find /htdocs -type f -print0 | xargs -0 chmod 0644
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/
|
||||
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/
|
||||
|
||||
HEALTHCHECK CMD curl -f http://localhost -A "HealthCheck" || exit 1
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
# Exit on non defined variables and on non zero exit codes
|
||||
set -eu
|
||||
|
||||
# Get/Set Variables
|
||||
# + ---------- + #
|
||||
# | -- VARS -- | #
|
||||
# + ---------- + #
|
||||
|
||||
SERVER_ADMIN="${SERVER_ADMIN:-you@example.com}"
|
||||
HTTP_SERVER_NAME="${HTTP_SERVER_NAME:-localhost}"
|
||||
HTTPS_SERVER_NAME="${HTTPS_SERVER_NAME:-localhost}"
|
||||
|
@ -12,21 +15,37 @@ TZ="${TZ:-UTC}"
|
|||
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-256M}"
|
||||
UPLOAD_MAX_FILESIZE="${UPLOAD_MAX_FILESIZE:-8M}"
|
||||
|
||||
echo 'Updating Configuration: Apache Base (/etc/apache2/httpd.conf)'
|
||||
# If TRUE, outputs pre and post-change config files, if a /debug folder has also been mounted.
|
||||
# i.e. - '/opt/docker/configs/littlelink/debug:/debug:rw'
|
||||
# Useful for comparing (and fixing) changes, if necessary.
|
||||
DEBUG="TRUE"
|
||||
|
||||
echo '+ ------------------------------------------------------------------ +'
|
||||
echo '| LITTLELINK CUSTOM |'
|
||||
|
||||
# + ---------------- + #
|
||||
# | -- HTTPD.CONF -- | #
|
||||
# + ---------------- + #
|
||||
|
||||
echo '+ ------------------------------------------------------------------ +'
|
||||
echo '| Updating Configuration: Apache Base (/etc/apache2/httpd.conf) |'
|
||||
|
||||
# ALTER: Server Admin, Name, Document Root.
|
||||
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.BEFORE.conf;fi
|
||||
|
||||
# Change Server Admin, Name, Document Root
|
||||
sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/httpd.conf
|
||||
sed -i "s/#ServerName\ www.example.com:80/ServerName\ ${HTTP_SERVER_NAME}/" /etc/apache2/httpd.conf
|
||||
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/httpd.conf
|
||||
sed -i 's#Directory "/var/www/localhost/htdocs"#Directory "/htdocs"#g' /etc/apache2/httpd.conf
|
||||
sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf
|
||||
|
||||
# Change TransferLog after ErrorLog
|
||||
# ALTER: TransferLog after ErrorLog.
|
||||
sed -i 's#^ErrorLog .*#ErrorLog "logs/error.log"#g' /etc/apache2/httpd.conf
|
||||
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
|
||||
sed -i 's#CustomLog .* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
|
||||
sed -i 's#CustomLog logs.* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
|
||||
|
||||
# Re-define LogLevel
|
||||
# ALTER: LogLevel.
|
||||
sed -i "s#^LogLevel .*#LogLevel ${LOG_LEVEL}#g" /etc/apache2/httpd.conf
|
||||
|
||||
# Enable commonly used apache modules
|
||||
|
@ -35,9 +54,18 @@ sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/
|
|||
sed -i 's/#LoadModule\ logio_module/LoadModule\ logio_module/' /etc/apache2/httpd.conf
|
||||
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
|
||||
|
||||
echo 'Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf)'
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.AFTER.conf;fi
|
||||
|
||||
# + -------------- + #
|
||||
# | -- SSL.CONF -- | #
|
||||
# + -------------- + #
|
||||
|
||||
echo '| Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf) |'
|
||||
|
||||
# ALTER: SSL DocumentRoot and Log locations
|
||||
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.BEFORE.conf;fi
|
||||
|
||||
# SSL DocumentRoot and Log locations
|
||||
sed -i 's#^ErrorLog .*#ErrorLog "logs/ssl-error.log"#g' /etc/apache2/conf.d/ssl.conf
|
||||
sed -i "s/^TransferLog .*/#TransferLog \"logs\/ssl-transfer.log\"\nLogLevel ${LOG_LEVEL}/g" /etc/apache2/conf.d/ssl.conf
|
||||
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
|
|||
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
|
||||
sed -i '/.*%{SSL_PROTOCOL}x.*/d' /etc/apache2/conf.d/ssl.conf
|
||||
|
||||
echo 'Updating Configuration: PHP (/etc/php8/php.ini)'
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.AFTER.conf;fi
|
||||
|
||||
# Modify php memory limit and timezone
|
||||
# + ------------- + #
|
||||
# | -- PHP.INI -- | #
|
||||
# + ------------- + #
|
||||
|
||||
echo '| Updating Configuration: PHP (/etc/php8/php.ini) |'
|
||||
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.BEFORE.ini;fi
|
||||
|
||||
# ALTER: Modify php memory limit and timezone
|
||||
sed -i "s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/" /etc/php8/php.ini
|
||||
sed -i "s/upload_max_filesize = .*/upload_max_filesize = ${UPLOAD_MAX_FILESIZE}/" /etc/php8/php.ini
|
||||
sed -i "s#^;date.timezone =\$#date.timezone = \"${TZ}\"#" /etc/php8/php.ini
|
||||
|
||||
echo "is_llc_docker = true" >> /etc/php8/php.ini
|
||||
|
||||
echo 'Updating Configuration: Complete'
|
||||
echo 'Running Apache'
|
||||
if [[ ${DEBUG} == "TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.AFTER.ini;fi
|
||||
|
||||
# + ---------- + #
|
||||
# | -- MISC -- | #
|
||||
# + ---------- + #
|
||||
|
||||
echo '| Updating Configuration: Complete |'
|
||||
echo '| ------------------------------------------------------------------ |'
|
||||
echo '| Running Apache |'
|
||||
echo '+ ------------------------------------------------------------------ +'
|
||||
echo
|
||||
|
||||
httpd -D FOREGROUND
|
||||
|
|
Loading…
Reference in a new issue