Skip to content

Commit 8d75802

Browse files
Merge pull request #20 from STaRDoGG/main
Several changes
2 parents 0c72b57 + 4f7443d commit 8d75802

2 files changed

Lines changed: 39 additions & 16 deletions

File tree

Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUN apk --no-cache --update \
2828
php8-pdo_sqlite \
2929
php8-phar \
3030
php8-session \
31+
tzdata \
3132
php8-xml \
3233
php8-tokenizer \
3334
php8-zip \
@@ -36,12 +37,23 @@ RUN apk --no-cache --update \
3637
COPY littlelink-custom /htdocs
3738
RUN chown -R apache:apache /htdocs
3839
RUN find /htdocs -type d -print0 | xargs -0 chmod 0755
39-
RUN find /htdocs -type f -print0 | xargs -0 chmod 0644
40+
RUN find /htdocs -type f -print0 | xargs -0 chmod 0644
4041

4142
EXPOSE 80 443
4243

43-
ADD docker-entrypoint.sh /
44+
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/
4445

45-
HEALTHCHECK CMD wget -q --no-cache --spider localhost
46+
HEALTHCHECK CMD curl -f http://localhost -A "HealthCheck" || exit 1
4647

47-
ENTRYPOINT ["/docker-entrypoint.sh"]
48+
# Forward Apache access and error logs to Docker's log collector.
49+
# Optional last line adds extra verbosity with for example:
50+
# [ssl:info] [pid 33] [client 10.0.5.8:45542] AH01964: Connection to child 2 established (server your.domain:443)
51+
RUN ln -sf /dev/stdout /var/www/logs/access.log \
52+
&& ln -sf /dev/stderr /var/www/logs/error.log \
53+
&& ln -sf /dev/stderr /var/www/logs/ssl-access.log
54+
# && ln -sf /dev/stderr /var/www/logs/ssl-error.log
55+
56+
# Set console entry path
57+
WORKDIR /htdocs/littlelink
58+
59+
CMD ["docker-entrypoint.sh"]

docker-entrypoint.sh

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

6+
# Get/Set Variables
67
SERVER_ADMIN="${SERVER_ADMIN:-you@example.com}"
78
HTTP_SERVER_NAME="${HTTP_SERVER_NAME:-localhost}"
89
HTTPS_SERVER_NAME="${HTTPS_SERVER_NAME:-localhost}"
@@ -11,33 +12,42 @@ TZ="${TZ:-UTC}"
1112
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-256M}"
1213
UPLOAD_MAX_FILESIZE="${UPLOAD_MAX_FILESIZE:-8M}"
1314

14-
echo 'Updating configurations'
15+
echo 'Updating Configuration: Apache Base (/etc/apache2/httpd.conf)'
1516

1617
# Change Server Admin, Name, Document Root
1718
sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/httpd.conf
18-
sed -i "s/#ServerName\ localhost:80/ServerName\ ${HTTP_SERVER_NAME}/" /etc/apache2/httpd.conf
19+
sed -i "s/#ServerName\ www.example.com:80/ServerName\ ${HTTP_SERVER_NAME}/" /etc/apache2/httpd.conf
1920
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/httpd.conf
2021
sed -i 's#Directory "/var/www/localhost/htdocs"#Directory "/htdocs"#g' /etc/apache2/httpd.conf
2122
sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf
2223

2324
# Change TransferLog after ErrorLog
24-
sed -i 's#^ErrorLog .*#ErrorLog "/dev/stderr"\nTransferLog "/dev/stdout"#g' /etc/apache2/httpd.conf
25-
sed -i 's#CustomLog .* combined#CustomLog "/dev/stdout" combined#g' /etc/apache2/httpd.conf
26-
27-
# SSL DocumentRoot and Log locations
28-
sed -i 's#^ErrorLog .*#ErrorLog "/dev/stderr"#g' /etc/apache2/conf.d/ssl.conf
29-
sed -i 's#^TransferLog .*#TransferLog "/dev/stdout"#g' /etc/apache2/conf.d/ssl.conf
30-
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/conf.d/ssl.conf
31-
sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/conf.d/ssl.conf
32-
sed -i "s/ServerName\ localhost:443/ServerName\ ${HTTPS_SERVER_NAME}/" /etc/apache2/conf.d/ssl.conf
25+
sed -i 's#^ErrorLog .*#ErrorLog "logs/error.log"#g' /etc/apache2/httpd.conf
26+
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
3328

3429
# Re-define LogLevel
3530
sed -i "s#^LogLevel .*#LogLevel ${LOG_LEVEL}#g" /etc/apache2/httpd.conf
3631

3732
# Enable commonly used apache modules
38-
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
3933
sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf
4034
sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/httpd.conf
35+
sed -i 's/#LoadModule\ logio_module/LoadModule\ logio_module/' /etc/apache2/httpd.conf
36+
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
37+
38+
echo 'Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf)'
39+
40+
# SSL DocumentRoot and Log locations
41+
sed -i 's#^ErrorLog .*#ErrorLog "logs/ssl-error.log"#g' /etc/apache2/conf.d/ssl.conf
42+
sed -i "s/^TransferLog .*/#TransferLog \"logs\/ssl-transfer.log\"\nLogLevel ${LOG_LEVEL}/g" /etc/apache2/conf.d/ssl.conf
43+
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/conf.d/ssl.conf
44+
sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/conf.d/ssl.conf
45+
sed -i "s/ServerName\ www.example.com:443/ServerName\ ${HTTPS_SERVER_NAME}/" /etc/apache2/conf.d/ssl.conf
46+
47+
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
48+
sed -i '/.*%{SSL_PROTOCOL}x.*/d' /etc/apache2/conf.d/ssl.conf
49+
50+
echo 'Updating Configuration: PHP (/etc/php8/php.ini)'
4151

4252
# Modify php memory limit and timezone
4353
sed -i "s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/" /etc/php8/php.ini
@@ -46,6 +56,7 @@ sed -i "s#^;date.timezone =\$#date.timezone = \"${TZ}\"#" /etc/php8/php.ini
4656

4757
echo "is_llc_docker = true" >> /etc/php8/php.ini
4858

59+
echo 'Updating Configuration: Complete'
4960
echo 'Running Apache'
5061

5162
httpd -D FOREGROUND

0 commit comments

Comments
 (0)