forked from LinkStackOrg/linkstack-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2021981
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM alpine:3.16 | ||
LABEL maintainer="JulianPrieber" | ||
LABEL description="LittleLink Custom Docker" | ||
|
||
# Setup apache and php | ||
RUN apk --no-cache --update \ | ||
add apache2 \ | ||
apache2-ssl \ | ||
curl \ | ||
php8-apache2 \ | ||
php8-bcmath \ | ||
php8-bz2 \ | ||
php8-calendar \ | ||
php8-common \ | ||
php8-ctype \ | ||
php8-curl \ | ||
php8-dom \ | ||
php8-gd \ | ||
php8-iconv \ | ||
php8-mbstring \ | ||
php8-mysqli \ | ||
php8-mysqlnd \ | ||
php8-openssl \ | ||
php8-pdo_mysql \ | ||
php8-pdo_pgsql \ | ||
php8-pdo_sqlite \ | ||
php8-phar \ | ||
php8-session \ | ||
php8-xml \ | ||
php8-tokenizer \ | ||
php8-zip \ | ||
&& mkdir /htdocs | ||
|
||
COPY littlelink-custom /htdocs | ||
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 | ||
|
||
ADD docker-entrypoint.sh / | ||
|
||
HEALTHCHECK CMD wget -q --no-cache --spider localhost | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/sh | ||
|
||
# Exit on non defined variables and on non zero exit codes | ||
set -eu | ||
|
||
echo 'Building the container' | ||
|
||
docker build ./ -t alpine-apache-php-ci:latest | ||
|
||
NET="${DOCKER_NETWORK:-alpine-apache-php-autotest}" | ||
|
||
# use failure to switch on create | ||
docker network inspect ${NET} 1>/dev/null 2> /dev/null || docker network create ${NET} | ||
|
||
echo 'Preparing test folder' | ||
|
||
TMP_DIR="$(mktemp -d --suffix alpine-apache-php)" | ||
|
||
printf "<?php \n\ | ||
echo 'PHP: ' . PHP_MAJOR_VERSION . PHP_EOL;\n\ | ||
echo 'Admin: ' . \$_SERVER['SERVER_ADMIN'] . PHP_EOL;\n\ | ||
echo 'Host: ' . \$_SERVER['SERVER_NAME'] . PHP_EOL;\n\ | ||
echo 'Memory-limit: ' . ini_get('memory_limit') . PHP_EOL;\n\ | ||
echo 'Timezone: ' . ini_get('date.timezone') . PHP_EOL;\n\ | ||
" > "${TMP_DIR}/index.php" | ||
|
||
chmod 777 "${TMP_DIR}" | ||
chmod 666 "${TMP_DIR}/index.php" | ||
|
||
echo 'Running test containers' | ||
|
||
# stop if exists or silently exit | ||
docker stop alpine-apache-php-test 1>/dev/null 2> /dev/null || echo '' >/dev/null | ||
|
||
docker run --rm --detach \ | ||
--name alpine-apache-php-test \ | ||
--network ${NET} \ | ||
--volume ${TMP_DIR}:/htdocs \ | ||
--env HTTP_SERVER_NAME="www.example.xyz" \ | ||
--env HTTPS_SERVER_NAME="www.example.xyz" \ | ||
--env SERVER_ADMIN="[email protected]" \ | ||
--env TZ="Europe/Paris" \ | ||
--env PHP_MEMORY_LIMIT="512M" \ | ||
alpine-apache-php-ci:latest 1>/dev/null | ||
|
||
|
||
# stop if exists or silently exit | ||
docker stop alpine-apache-php-test-normal 1>/dev/null 2> /dev/null || echo '' >/dev/null | ||
|
||
docker run --rm --detach \ | ||
--name alpine-apache-php-test-normal \ | ||
--network ${NET} \ | ||
--volume ${TMP_DIR}:/htdocs \ | ||
alpine-apache-php-ci:latest 1>/dev/null | ||
|
||
echo '' | ||
echo 'Running custom tests' | ||
|
||
docker run --rm --network ${NET} curlimages/curl:latest -s -k https://alpine-apache-php-test -H 'Host: www.example.xyz' | ||
docker run --rm --network ${NET} curlimages/curl:latest -s http://alpine-apache-php-test | ||
docker run --rm --network ${NET} curlimages/curl:latest -s -k https://alpine-apache-php-test | ||
|
||
echo '' | ||
echo 'Running normal tests' | ||
|
||
docker run --rm --network ${NET} curlimages/curl:latest -s -k https://alpine-apache-php-test-normal -H 'Host: www.example.xyz' | ||
docker run --rm --network ${NET} curlimages/curl:latest -s http://alpine-apache-php-test-normal | ||
docker run --rm --network ${NET} curlimages/curl:latest -s -k https://alpine-apache-php-test-normal | ||
|
||
echo '' | ||
echo 'Cleaning up' | ||
docker stop alpine-apache-php-test 1>/dev/null | ||
docker stop alpine-apache-php-test-normal 1>/dev/null | ||
docker network rm ${NET} 1>/dev/null | ||
|
||
rm "${TMP_DIR}/index.php" | ||
rmdir "${TMP_DIR}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
# Exit on non defined variables and on non zero exit codes | ||
set -eu | ||
|
||
SERVER_ADMIN="${SERVER_ADMIN:-you@example.com}" | ||
HTTP_SERVER_NAME="${HTTP_SERVER_NAME:-www.example.com}" | ||
HTTPS_SERVER_NAME="${HTTPS_SERVER_NAME:-www.example.com}" | ||
LOG_LEVEL="${LOG_LEVEL:-info}" | ||
TZ="${TZ:-UTC}" | ||
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-256M}" | ||
|
||
echo 'Updating configurations' | ||
|
||
# Change Server Admin, Name, Document Root | ||
sed -i "s/ServerAdmin\ [email protected]/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 | ||
sed -i 's#^ErrorLog .*#ErrorLog "/dev/stderr"\nTransferLog "/dev/stdout"#g' /etc/apache2/httpd.conf | ||
sed -i 's#CustomLog .* combined#CustomLog "/dev/stdout" combined#g' /etc/apache2/httpd.conf | ||
|
||
# SSL DocumentRoot and Log locations | ||
sed -i 's#^ErrorLog .*#ErrorLog "/dev/stderr"#g' /etc/apache2/conf.d/ssl.conf | ||
sed -i 's#^TransferLog .*#TransferLog "/dev/stdout"#g' /etc/apache2/conf.d/ssl.conf | ||
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/conf.d/ssl.conf | ||
sed -i "s/ServerAdmin\ [email protected]/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/conf.d/ssl.conf | ||
sed -i "s/ServerName\ www.example.com:443/ServerName\ ${HTTPS_SERVER_NAME}/" /etc/apache2/conf.d/ssl.conf | ||
|
||
# Re-define LogLevel | ||
sed -i "s#^LogLevel .*#LogLevel ${LOG_LEVEL}#g" /etc/apache2/httpd.conf | ||
|
||
# Enable commonly used apache modules | ||
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf | ||
sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf | ||
sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/httpd.conf | ||
|
||
# Modify php memory limit and timezone | ||
sed -i "s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/" /etc/php8/php.ini | ||
sed -i "s#^;date.timezone =\$#date.timezone = \"${TZ}\"#" /etc/php8/php.ini | ||
|
||
echo 'Running Apache' | ||
|
||
httpd -D FOREGROUND |