Commit 87384783 authored by Dave Lane's avatar Dave Lane

updated to add xdebug container option for development, and update to PHP 7.2 elsewhere

parent c4ee08a0
FROM oeru/php7.0-fpm-jessie
FROM oeru/php72-fpm
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)
# note: cron is already installed.
......
# Caching configuration
# https://easyengine.io/wordpress-nginx/tutorials/multisite/subdirectories/fastcgi-cache-with-purging/
#
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WORDPRESS:500m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
# from https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
#
# using subdir approach, not subdomain...
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
#Ref: http://wordpress.org/extend/plugins/nginx-helper/
include /var/www/html/wp-content/uploads/nginx-helper/map.conf;
}
# statements for each of your virtual hosts to this file
server {
listen 0.0.0.0:80;
root /var/www/html;
index index.php index.html index.htm;
#
# Caching configuration
#
#fastcgi_cache start
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# end main Caching functionality
#
# Flow of serving pages
#
# from https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/html/wp-content/blogs.dir;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
# from https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04
# with other bits from https://premium.wpmudev.org/blog/wordpress-multisite-wordpress-nginx/
location / {
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_keep_conn on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors on;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
#
# caching functionality
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
#
# caching functionality
location ~ /purge(/.*) { fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; }
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { allow all; log_not_found off; access_log off; }
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
}
default.conf-development
\ No newline at end of file
FROM php:7.0-fpm-jessie
FROM php:7.2-fpm
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)
ENV PHPREDIS_VERSION 3.1.4
ENV PHPREDIS_VERSION 4.3.0
# Install PHP extensions
RUN apt-get update && apt-get install -y apt-utils git less libbz2-dev libc-client-dev \
......@@ -12,17 +12,21 @@ RUN apt-get install -y net-tools vim dnsutils
RUN apt-get install -y cron msmtp
RUN rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos
RUN docker-php-ext-install bz2 curl gd imap intl mbstring mcrypt mysqli \
RUN docker-php-ext-install bz2 curl gd imap intl mbstring mysqli \
opcache pdo pdo_mysql pspell soap xmlrpc zip
# set up Redis support for php
RUN docker-php-source extract \
&& curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& docker-php-source delete \
&& curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
#RUN docker-php-source extract \
# && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
# && tar xfz /tmp/redis.tar.gz \
# && rm -r /tmp/redis.tar.gz \
# && mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
# && docker-php-ext-install redis \
# && docker-php-source delete \
# && curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
# && chmod +x wp-cli.phar \
# && mv wp-cli.phar /usr/local/bin/wp
RUN pecl install redis && docker-php-ext-enable redis
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& mv wp-cli.phar /usr/local/bin/wp
......@@ -38,6 +42,8 @@ RUN set -ex \
echo 'upload_max_filesize = 100M'; \
echo 'post_max_size = 150M'; \
echo 'memory_limit = 250M'; \
echo 'max_execution_time = 500'; \
echo 'request_terminate_timeout = 500'; \
echo '[opcache]'; \
echo 'opcache.enable = 1'; \
echo 'opcache.memory_consumption = 128'; \
......
FROM oeru/php72-fpm
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)
RUN pecl install xdebug-2.7.1 && docker-php-ext-enable xdebug
RUN set -ex \
&& { \
# echo 'catch_workers_output = no'; \
echo 'opcache.enable = 0'; \
echo 'xdebug.collect_params = 1'; \
echo 'xdebug.idekey = xdebug-atom'; \
# echo 'xdebug.remote_autostart = 1'; \
echo 'xdebug.remote_enable = 1'; \
echo 'xdebug.remote_timeout = 600'; \
echo 'xdebug.remote_port = 9001'; \
} | tee /usr/local/etc/php/conf.d/xdebug.ini;
EXPOSE 9001
# Copy init scripts and custom .htaccess
CMD ["php-fpm"]
FROM php:7.0-fpm-jessie
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)
# Install PHP extensions
RUN apt-get update && apt-get install -y apt-utils git less libbz2-dev libc-client-dev \
libcurl4-gnutls-dev libicu-dev libkrb5-dev libmcrypt-dev libpng-dev \
libpspell-dev libssl-dev libxml2-dev mariadb-client telnet unzip zip
RUN apt-get install -y net-tools vim dnsutils
# install cron and msmtp for outgoing email
RUN apt-get install -y cron msmtp
RUN rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos
RUN docker-php-ext-install bz2 curl gd imap intl mbstring mcrypt mysqli \
opcache pdo pdo_mysql pspell soap xmlrpc zip
# address app-specific config requirements
RUN echo "log_errors = on" > /usr/local/etc/php/conf.d/php.ini
RUN echo "display_errors = off" >> /usr/local/etc/php/conf.d/php.ini
RUN echo "always_populate_raw_post_data = -1" >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'date.timezone = "Pacific/Auckland"' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'cgi.fix_pathinfo = 0' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'sendmail_path = /usr/bin/msmtp -t' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'upload_max_filesize = 100M' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'post_max_size = 150M' >> /usr/local/etc/php/conf.d/php.ini
RUN echo '[opcache]' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.enable = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.memory_consumption = 128' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.max_accelerated_files = 8000' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.revalidate_freq = 60' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.use_cwd = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.validate_timestamps = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.save_comments = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.enable_file_override = 0' >> /usr/local/etc/php/conf.d/php.ini
# the PHP-fpm configuration
RUN echo 'security.limit_extensions = .php' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'catch_workers_output = yes' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_flag[display_errors] = off' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_value[error_log] = /usr/local/var/log/fpm-php.www.log' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_flag[log_errors] = on' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_value[memory_limit] = 120M' >> /usr/local/etc/php-fpm.d/www.conf
VOLUME /var/www/html
# Copy init scripts and custom .htaccess
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
FROM php:7.0-fpm-jessie
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)
ENV PHPREDIS_VERSION 3.1.4
# Install PHP extensions
RUN apt-get update && apt-get install -y apt-utils git less libbz2-dev libc-client-dev \
libcurl4-gnutls-dev libicu-dev libkrb5-dev libmcrypt-dev libpng-dev \
libpspell-dev libssl-dev libxml2-dev mariadb-client telnet unzip zip
RUN apt-get install -y net-tools vim dnsutils
# install cron and msmtp for outgoing email
RUN apt-get install -y cron msmtp
RUN rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos
RUN docker-php-ext-install bz2 curl gd imap intl mbstring mcrypt mysqli \
opcache pdo pdo_mysql pspell soap xmlrpc zip
# set up Redis support for php
RUN docker-php-source extract \
&& curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& docker-php-source delete \
&& curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& mv wp-cli.phar /usr/local/bin/wp
# address app-specific config requirements
RUN echo "log_errors = on" > /usr/local/etc/php/conf.d/php.ini
RUN echo "display_errors = off" >> /usr/local/etc/php/conf.d/php.ini
RUN echo "always_populate_raw_post_data = -1" >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'date.timezone = "Pacific/Auckland"' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'cgi.fix_pathinfo = 0' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'sendmail_path = /usr/bin/msmtp -t' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'upload_max_filesize = 100M' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'post_max_size = 150M' >> /usr/local/etc/php/conf.d/php.ini
# OpCache work
RUN echo '[opcache]' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.enable = 1' >> /usr/local/etc/php/conf.d/php.ini
#RUN echo 'opcache.enable_cli = 1' >> /usr/local/etc/php/conf.d/php.ini
#RUN echo 'opcache.interned_strings_buffer = 8' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.memory_consumption = 128' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.max_accelerated_files = 8000' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.revalidate_freq = 60' >> /usr/local/etc/php/conf.d/php.ini
#RUN echo 'opcache.fast_shutdown = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.use_cwd = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.validate_timestamps = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.save_comments = 1' >> /usr/local/etc/php/conf.d/php.ini
RUN echo 'opcache.enable_file_override = 0' >> /usr/local/etc/php/conf.d/php.ini
# the PHP-fpm configuration
RUN echo 'security.limit_extensions = .php' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'catch_workers_output = yes' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_flag[display_errors] = off' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_value[error_log] = /usr/local/var/log/fpm-php.www.log' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_flag[log_errors] = on' >> /usr/local/etc/php-fpm.d/www.conf
RUN echo 'php_admin_value[memory_limit] = 120M' >> /usr/local/etc/php-fpm.d/www.conf
VOLUME /var/www/html
# Copy init scripts and custom .htaccess
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
This container is called
`oeru/php7.0-fpm-jessie`
We build it with
`docker build -t oeru/php7.0-fpm-jessie .`
you can replace the `oeru/` with your preferred name.
dave@oerfoundation.org
#!/bin/bash
set -e
# if CREATE_DB is set, then we probably want to create a DB
if [ -v CREATE_DB ] ; then
# If the DB user is 'root' then use the MySQL root password env var
: ${DB_USER:=root}
if [ "$DB_USER" = 'root' ]; then
: ${DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
fi
: ${DB_NAME:=wordpress}
if [ -z "$DB_PASSWORD" ]; then
echo >&2 "error: missing required DB_PASSWORD environment variable"
echo >&2 " Did you forget to -e DB_PASSWORD=... ?"
echo >&2
echo >&2 " (Also of interest might be DB_USER and DB_NAME.)"
exit 1
fi
else
echo >&2 "Assuming no database, or that any required databases already exist..."
fi
# set up authenticating SMTP...
if [ -v SMTP_HOST ] ; then
if ! [ -e /etc/msmtprc ] ; then
echo >&2 "writing /etc/msmtprc"
tee <<EOF > /etc/msmtprc
#
# This was generated by a template in the entrypoint.sh script
# to create a valid msmtprc configuration with environment
# variables set in your docker-compose.yml file.
#
# For more quirky configurations, this might require some
# manual tweaking.
#
# easy docker container outgoing mail
defaults
logfile /tmp/msmtp.log
# this assumes that the SMTP server has TLS... which
# any modern server should...
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account RemoteHost
# server details
host $SMTP_HOST
from $SMTP_REPLYTO_EMAIL
port $SMTP_PORT
# SMTP authentication details
auth on
user $SMTP_AUTH_USER
password $SMTP_AUTH_PASSWORD
account default : RemoteHost
EOF
else
echo >&2 "/etc/msmtprc already in place! Not overwriting."
fi
else
echo >&2 "not configuring MSMTP - set SMTP_HOST and related environment values to enable."
fi
# run composer to set up dependencies if not already there...
#if ! [ -e vendor/autoload.php ]; then
# echo >&2 "installing dependencies with Composer"
# if ! [ -e /usr/local/bin/composer ]; then
# echo >&2 "first getting Composer"
# # Get Composer
# curl -S https://getcomposer.org/installer | php
# chmod a+x composer.phar
# mv composer.phar /usr/local/bin/composer
# fi
#else
# echo >&2 "vendor dependencies already in place."
#fi
if ! [ -e /usr/local/bin/wp ] ; then
echo >&2 "installing wp-cli as /usr/local/bin/wp!"
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
fi
exec "$@"
<?php
// Args: 0 => makedb.php, 1 => "$MAUTIC_DB_HOST", 2 => "$MAUTIC_DB_USER", 3 => "$MAUTIC_DB_PASSWORD", 4 => "$MAUTIC_DB_NAME"
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Mautic database is present\n");
if (strpos($argv[1], ':') !== false)
{
list($host, $port) = explode(':', $argv[1], 2);
}
else
{
$host = $argv[1];
$port = 3306;
}
$maxTries = 10;
do
{
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port);
if ($mysql->connect_error)
{
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . ''))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
#
# This is a template used by the entrypoint.sh script
# to create a valid msmtprc configuration with environment
# variables set in your docker-compose.yml file.
#
# For more quirky configurations, this might require some
# manual tweaking.
#
# easy docker container outgoing mail
defaults
logfile /tmp/msmtp.log
# this assumes that the SMTP server has TLS... which
# any modern server should...
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account RemoteHost
# server details
host SMTP_HOST
from SMTP_REPLYTO_EMAIL
port SMTP_PORT
# SMTP authentication details
auth on
user SMTP_AUTH_USER
password SMTP_AUTH_PASSWORD
account default : RemoteHost
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment