Skip to content

Commit

Permalink
new 5/apache/php7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
adixon committed Mar 11, 2022
1 parent f69dfb5 commit 9be8320
Show file tree
Hide file tree
Showing 14 changed files with 325 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 5/apache/php7.4/admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ARG REPOSITORY_FROM=blackflysolutions/
ARG REPOSITORY_FROM=""
FROM ${REPOSITORY_FROM}ceratopogonidae:5-php7.4-apache-wordpress
# an extended version of the webserver image, adding extra packages and scripts
RUN apt-get update \
&& apt-get install -y mariadb-client sudo vim git zip unzip netcat rsync \
&& apt-get purge -y
COPY wp-cli.phar /usr/local/bin/wp
COPY wait-for-it.sh /usr/local/bin/wait-for-it.sh
COPY core-install.sh /usr/local/bin/core-install.sh
COPY admindb.sh /usr/local/bin/admindb.sh
RUN chmod ugo+x /usr/local/bin/wp && chmod ugo+x /usr/local/bin/*.sh
# provide a non-root user to own drupal code
RUN useradd -u 1978 -g www-data -ms /bin/bash drupal
COPY admin.conf /etc/apache2/conf-available
RUN a2enconf admin
# CMD["apache2-foreground"]
# Run the same initialization script that vhttp does, and then the admin one.
# CMD /usr/local/bin/admin.sh && apache2-foreground
8 changes: 8 additions & 0 deletions 5/apache/php7.4/admin/admin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Overrides to apache for the admin image
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
4 changes: 4 additions & 0 deletions 5/apache/php7.4/admin/admindb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# simple script to launch mysql as root
echo "db: ${WORDPRESS_DB_NAME}";
mysql -u root -p$WORDPRESS_DB_PASSWORD -h vsql $WORDPRESS_DB_NAME
15 changes: 15 additions & 0 deletions 5/apache/php7.4/admin/core-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Use wp-cli to do a standard Wordpress install, if no settings file exists
/usr/local/bin/wait-for-it.sh vsql:3306
# this will destroy any existing db, should I check first?
cd /var/www/html
mkdir -p /var/www/html/wp-content/uploads
chown www-data:www-data /var/www/html/wp-content/uploads
echo "Installing WordPress using $VSITE_SITE_NAME, $VSITE_ADMIN_MAIL, $VSITE_ADMIN_NAME"
sudo -E -u www-data wp core install \
--url="$VSITE_DOMAIN" \
--title="$VSITE_SITE_NAME" \
--admin_user="$VSITE_ADMIN_NAME" \
--admin_email="$VSITE_ADMIN_MAIL"
wp plugin install one-time-login --activate --allow-root
echo "Site Installation Completed"
161 changes: 161 additions & 0 deletions 5/apache/php7.4/admin/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available

cmdname=$(basename $0)

echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }

usage()
{
cat << USAGE >&2
Usage:
$cmdname host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit 1
}

wait_for()
{
if [[ $TIMEOUT -gt 0 ]]; then
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
else
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
fi
start_ts=$(date +%s)
while :
do
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
result=$?
if [[ $result -eq 0 ]]; then
end_ts=$(date +%s)
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
break
fi
sleep 1
done
return $result
}

wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
else
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
fi
PID=$!
trap "kill -INT -$PID" INT
wait $PID
RESULT=$?
if [[ $RESULT -ne 0 ]]; then
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
fi
return $RESULT
}

# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
*:* )
hostport=(${1//:/ })
HOST=${hostport[0]}
PORT=${hostport[1]}
shift 1
;;
--child)
CHILD=1
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-s | --strict)
STRICT=1
shift 1
;;
-h)
HOST="$2"
if [[ $HOST == "" ]]; then break; fi
shift 2
;;
--host=*)
HOST="${1#*=}"
shift 1
;;
-p)
PORT="$2"
if [[ $PORT == "" ]]; then break; fi
shift 2
;;
--port=*)
PORT="${1#*=}"
shift 1
;;
-t)
TIMEOUT="$2"
if [[ $TIMEOUT == "" ]]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
CLI="$@"
break
;;
--help)
usage
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done

if [[ "$HOST" == "" || "$PORT" == "" ]]; then
echoerr "Error: you need to provide a host and port to test."
usage
fi

TIMEOUT=${TIMEOUT:-60}
STRICT=${STRICT:-0}
CHILD=${CHILD:-0}
QUIET=${QUIET:-0}

if [[ $CHILD -gt 0 ]]; then
wait_for
RESULT=$?
exit $RESULT
else
if [[ $TIMEOUT -gt 0 ]]; then
wait_for_wrapper
RESULT=$?
else
wait_for
RESULT=$?
fi
fi

if [[ $CLI != "" ]]; then
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
echoerr "$cmdname: strict mode, refusing to execute subprocess"
exit $RESULT
fi
exec $CLI
else
exit $RESULT
fi
Binary file added 5/apache/php7.4/admin/wp-cli.phar
Binary file not shown.
55 changes: 55 additions & 0 deletions 5/apache/php7.4/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.4'

services:

vhttp:
image: blackflysolutions/ceratopogonidae:5-php7.4-apache-wordpress
ports:
- "80/tcp"
expose:
- "80"
environment:
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- VSITE
- VSITE_DOMAIN
- VSITE_DOMAIN_ALTERNATIVES
volumes:
- vwp:/var/www/html

vsql:
image: blackflysolutions/mariadb:10.4
environment:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD
volumes:
- vdb:/var/lib/mysql

admin:
image: blackflysolutions/ceratopogonidae:5-php7.4-apache-admin
volumes:
- vwp:/var/www/html
environment:
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- VSITE_SITE_NAME
- VSITE_ADMIN_MAIL
- VSITE_ADMIN_NAME
- VSITE
- VSITE_DOMAIN
- VSITE_DOMAIN_ALTERNATIVES

depends_on:
- vsql
- vhttp


volumes:
vwp:
vdb:
4 changes: 4 additions & 0 deletions 5/apache/php7.4/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# docker pull wordpress:5-php7.4-apache
docker build -t ceratopogonidae:5-php7.4-apache-wordpress wordpress/
docker build -t ceratopogonidae:5-php7.4-apache-admin admin/
4 changes: 4 additions & 0 deletions 5/apache/php7.4/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# tag the containers in preparation for pushing them to the repo
docker push blackflysolutions/ceratopogonidae:5-php7.4-apache-wordpress
docker push blackflysolutions/ceratopogonidae:5-php7.4-apache-admin
4 changes: 4 additions & 0 deletions 5/apache/php7.4/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# tag the containers in preparation for pushing them to the repo
docker tag ceratopogonidae:5-php7.4-apache-wordpress blackflysolutions/ceratopogonidae:5-php7.4-apache-wordpress
docker tag ceratopogonidae:5-php7.4-apache-admin blackflysolutions/ceratopogonidae:5-php7.4-apache-admin
10 changes: 10 additions & 0 deletions 5/apache/php7.4/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM wordpress:5-php7.4-apache
RUN a2enmod expires
RUN apt-get update && apt-get install -y msmtp && \
apt-get clean && \
echo 'sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"' > /usr/local/etc/php/conf.d/mail.ini
COPY msmtprc /etc/msmtprc
# handle the varnish+hitch proxying and add browser caching
COPY htaccess /var/www/html/.htaccess
# increase some php defaults
COPY wordpress.ini /usr/local/etc/php/conf.d/
15 changes: 15 additions & 0 deletions 5/apache/php7.4/wordpress/htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|woff)$">
ExpiresActive On
ExpiresDefault A2592000
</FilesMatch>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
SetEnvIf X-Forwarded-Proto https HTTPS=on
18 changes: 18 additions & 0 deletions 5/apache/php7.4/wordpress/msmtprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default

# The SMTP smarthost, our docker host
host f.civicrm.ca

# Use port 25
port 25
tls off
tls_starttls off

# Construct envelope-from addresses of the form "[email protected]"
from [email protected]

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
8 changes: 8 additions & 0 deletions 5/apache/php7.4/wordpress/wordpress.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; custom php config stored in /usr/local/etc/php/conf.d
max_execution_time = 30
; http://php.net/post-max-size
post_max_size = 64M
; http://php.net/upload-max-filesize
upload_max_filesize = 64M
; allow big forms!
max_input_vars = 4000

0 comments on commit 9be8320

Please sign in to comment.