From c3614d7a3a45c72c6561f645443fbe8255d221e5 Mon Sep 17 00:00:00 2001 From: selim13 Date: Tue, 13 Sep 2016 16:12:01 +0300 Subject: [PATCH] 3.1-apache initial --- 3.1-apache/Dockerfile | 75 ++++++++ 3.1-apache/apache2/conf.d/mpm.conf | 9 + 3.1-apache/apache2/httpd.conf | 155 ++++++++++++++++ 3.1-apache/php5/conf.d/opcache-recomended.ini | 6 + 3.1-apache/php5/php-cli.ini | 2 + 3.1-apache/php5/php.ini | 18 ++ 3.1-apache/phpbb/config.php | 25 +++ 3.1-apache/start.sh | 27 +++ README.MD | 173 ++++++++++++++++++ docker-compose.yml | 21 +++ 10 files changed, 511 insertions(+) create mode 100644 3.1-apache/Dockerfile create mode 100644 3.1-apache/apache2/conf.d/mpm.conf create mode 100644 3.1-apache/apache2/httpd.conf create mode 100644 3.1-apache/php5/conf.d/opcache-recomended.ini create mode 100644 3.1-apache/php5/php-cli.ini create mode 100644 3.1-apache/php5/php.ini create mode 100644 3.1-apache/phpbb/config.php create mode 100755 3.1-apache/start.sh create mode 100644 README.MD create mode 100644 docker-compose.yml diff --git a/3.1-apache/Dockerfile b/3.1-apache/Dockerfile new file mode 100644 index 0000000..f10e54a --- /dev/null +++ b/3.1-apache/Dockerfile @@ -0,0 +1,75 @@ +FROM alpine:latest + +MAINTAINER Dmitry Seleznyov + +RUN apk add --no-cache curl \ + imagemagick \ + apache2 \ + php5-apache2 \ + php5-cli \ + php5-ctype \ + php5-opcache \ + php5-curl \ + php5-openssl \ + php5-ftp \ + php5-mysqli \ + php5-sqlite3 \ + php5-pgsql \ + php5-json \ + php5-xml \ + php5-zlib \ + php5-zip \ + php5-gd + +### phpBB +ENV PHPBB_VERSION 3.1.9 +ENV PHPBB_SHA256 '94d67899269dd871cd314b3f2d3275fc7b31f5e6856e56fa70f0aed8e47a3ac8' + +WORKDIR /tmp + +ADD https://www.phpbb.com/files/release/phpBB-${PHPBB_VERSION}.tar.bz2 phpbb.tar.bz2 +RUN echo "${PHPBB_SHA256} phpbb.tar.bz2" | sha256sum -c - \ + && tar -xjf phpbb.tar.bz2 \ + && mkdir /phpbb \ + && mkdir /phpbb/sqlite \ + && mv phpBB3 /phpbb/www +RUN rm -f phpbb.tar.bz2 + +COPY phpbb/config.php /phpbb/www + +### Server +RUN mkdir -p /run/apache2 \ + && chown apache:apache /run/apache2 + +COPY apache2/httpd.conf /etc/apache2 +COPY apache2/conf.d/* /etc/apache2/conf.d + +COPY php5/php.ini /etc/php5 +COPY php5/php-cli.ini /etc/php5 +COPY php5/conf.d/* /etc/php5/conf.d + +COPY start.sh /usr/local/bin + +RUN chown -R apache:apache /phpbb +WORKDIR /phpbb/www + +VOLUME /phpbb/sqlite +VOLUME /phpbb/www/files +VOLUME /phpbb/www/store +VOLUME /phpbb/www/images/avatars/upload + +ENV PHPBB_INSTALL= \ + PHPBB_DB_DRIVER=sqlite3 \ + PHPBB_DB_HOST=/phpbb/sqlite/sqlite.db \ + PHPBB_DB_PORT= \ + PHPBB_DB_NAME= \ + PHPBB_DB_USER= \ + PHPBB_DB_PASSWD= \ + PHPBB_DB_TABLE_PREFIX=phpbb_ \ + PHPBB_DB_AUTOMIGRATE= \ + PHPBB_DISPLAY_LOAD_TIME= \ + PHPBB_DEBUG= \ + PHPBB_DEBUG_CONTAINER= + +EXPOSE 80 +CMD ["start.sh"] \ No newline at end of file diff --git a/3.1-apache/apache2/conf.d/mpm.conf b/3.1-apache/apache2/conf.d/mpm.conf new file mode 100644 index 0000000..d96dfb1 --- /dev/null +++ b/3.1-apache/apache2/conf.d/mpm.conf @@ -0,0 +1,9 @@ +PidFile "/run/apache2/httpd.pid" + + + StartServers 5 + MinSpareServers 5 + MaxSpareServers 10 + MaxRequestWorkers 250 + MaxConnectionsPerChild 0 + \ No newline at end of file diff --git a/3.1-apache/apache2/httpd.conf b/3.1-apache/apache2/httpd.conf new file mode 100644 index 0000000..862a9b5 --- /dev/null +++ b/3.1-apache/apache2/httpd.conf @@ -0,0 +1,155 @@ +ServerTokens Prod + +ServerRoot /var/www + +Listen 80 + +LoadModule authn_file_module modules/mod_authn_file.so +#LoadModule authn_dbm_module modules/mod_authn_dbm.so +#LoadModule authn_anon_module modules/mod_authn_anon.so +#LoadModule authn_dbd_module modules/mod_authn_dbd.so +#LoadModule authn_socache_module modules/mod_authn_socache.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_user_module modules/mod_authz_user.so +#LoadModule authz_dbm_module modules/mod_authz_dbm.so +#LoadModule authz_owner_module modules/mod_authz_owner.so +#LoadModule authz_dbd_module modules/mod_authz_dbd.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule access_compat_module modules/mod_access_compat.so +LoadModule auth_basic_module modules/mod_auth_basic.so +#LoadModule auth_form_module modules/mod_auth_form.so +#LoadModule auth_digest_module modules/mod_auth_digest.so +#LoadModule allowmethods_module modules/mod_allowmethods.so +#LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule cache_module modules/mod_cache.so +#LoadModule cache_disk_module modules/mod_cache_disk.so +#LoadModule cache_socache_module modules/mod_cache_socache.so +#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so +#LoadModule socache_dbm_module modules/mod_socache_dbm.so +#LoadModule socache_memcache_module modules/mod_socache_memcache.so +#LoadModule watchdog_module modules/mod_watchdog.so +#LoadModule macro_module modules/mod_macro.so +#LoadModule dbd_module modules/mod_dbd.so +#LoadModule dumpio_module modules/mod_dumpio.so +#LoadModule echo_module modules/mod_echo.so +#LoadModule buffer_module modules/mod_buffer.so +#LoadModule data_module modules/mod_data.so +#LoadModule ratelimit_module modules/mod_ratelimit.so +LoadModule reqtimeout_module modules/mod_reqtimeout.so +#LoadModule ext_filter_module modules/mod_ext_filter.so +#LoadModule request_module modules/mod_request.so +#LoadModule include_module modules/mod_include.so +LoadModule filter_module modules/mod_filter.so +#LoadModule reflector_module modules/mod_reflector.so +#LoadModule substitute_module modules/mod_substitute.so +#LoadModule sed_module modules/mod_sed.so +#LoadModule charset_lite_module modules/mod_charset_lite.so +#LoadModule deflate_module modules/mod_deflate.so +LoadModule mime_module modules/mod_mime.so +LoadModule log_config_module modules/mod_log_config.so +#LoadModule log_debug_module modules/mod_log_debug.so +#LoadModule log_forensic_module modules/mod_log_forensic.so +#LoadModule logio_module modules/mod_logio.so +LoadModule env_module modules/mod_env.so +#LoadModule mime_magic_module modules/mod_mime_magic.so +#LoadModule expires_module modules/mod_expires.so +LoadModule headers_module modules/mod_headers.so +#LoadModule usertrack_module modules/mod_usertrack.so +#LoadModule unique_id_module modules/mod_unique_id.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule version_module modules/mod_version.so +#LoadModule remoteip_module modules/mod_remoteip.so +#LoadModule session_module modules/mod_session.so +#LoadModule session_cookie_module modules/mod_session_cookie.so +#LoadModule session_dbd_module modules/mod_session_dbd.so +#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so +#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so +#LoadModule dialup_module modules/mod_dialup.so +#LoadModule mpm_event_module modules/mod_mpm_event.so +LoadModule mpm_prefork_module modules/mod_mpm_prefork.so +#LoadModule mpm_worker_module modules/mod_mpm_worker.so +LoadModule unixd_module modules/mod_unixd.so +#LoadModule heartbeat_module modules/mod_heartbeat.so +#LoadModule heartmonitor_module modules/mod_heartmonitor.so +LoadModule status_module modules/mod_status.so +#LoadModule autoindex_module modules/mod_autoindex.so +#LoadModule asis_module modules/mod_asis.so +#LoadModule info_module modules/mod_info.so +#LoadModule suexec_module modules/mod_suexec.so + + #LoadModule cgid_module modules/mod_cgid.so + + + #LoadModule cgi_module modules/mod_cgi.so + +#LoadModule vhost_alias_module modules/mod_vhost_alias.so +#LoadModule negotiation_module modules/mod_negotiation.so +LoadModule dir_module modules/mod_dir.so +#LoadModule actions_module modules/mod_actions.so +#LoadModule speling_module modules/mod_speling.so +#LoadModule userdir_module modules/mod_userdir.so +LoadModule alias_module modules/mod_alias.so +LoadModule rewrite_module modules/mod_rewrite.so + +LoadModule negotiation_module modules/mod_negotiation.so + + + User apache + Group apache + + + +ServerAdmin you@example.com + +ServerSignature Off + +#ServerName www.example.com:80 + + + AllowOverride none + Require all denied + + +DocumentRoot "/phpbb/www" + + Options FollowSymLinks + AllowOverride All + Require all granted + + # Return 404 for all dot files (.htaccess, .git, etc...) + RedirectMatch 404 /\..*$ + + + + DirectoryIndex index.php index.html + + + + Require all denied + + +ErrorLog /dev/stderr +LogLevel warn + + + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + CustomLog /dev/stdout combined + + + + + TypesConfig /etc/apache2/mime.types + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + + + + + MIMEMagicFile /etc/apache2/magic + + +IncludeOptional /etc/apache2/conf.d/*.conf diff --git a/3.1-apache/php5/conf.d/opcache-recomended.ini b/3.1-apache/php5/conf.d/opcache-recomended.ini new file mode 100644 index 0000000..7964455 --- /dev/null +++ b/3.1-apache/php5/conf.d/opcache-recomended.ini @@ -0,0 +1,6 @@ +opcache.memory_consumption=128 +opcache.interned_strings_buffer=8 +opcache.max_accelerated_files=4000 +opcache.revalidate_freq=60 +opcache.fast_shutdown=1 +opcache.enable_cli=1 diff --git a/3.1-apache/php5/php-cli.ini b/3.1-apache/php5/php-cli.ini new file mode 100644 index 0000000..2d0627a --- /dev/null +++ b/3.1-apache/php5/php-cli.ini @@ -0,0 +1,2 @@ +[php] +memory_limit = -1 diff --git a/3.1-apache/php5/php.ini b/3.1-apache/php5/php.ini new file mode 100644 index 0000000..89b7bb0 --- /dev/null +++ b/3.1-apache/php5/php.ini @@ -0,0 +1,18 @@ +[PHP] +file_uploads = On +max_file_uploads = 2 +upload_max_filesize = 8M +post_max_size = 8M + +allow_url_fopen = On + +expose_php = Off +security.limit_extensions = .php + +output_buffering = On +display_errors = Off +log_errors = On +error_log = /dev/stderr + +[Date] +date.timezone = 'UTC' \ No newline at end of file diff --git a/3.1-apache/phpbb/config.php b/3.1-apache/phpbb/config.php new file mode 100644 index 0000000..2d40245 --- /dev/null +++ b/3.1-apache/phpbb/config.php @@ -0,0 +1,25 @@ + config.php +[[ "${PHPBB_INSTALL}" != "true" ]] && rm -rf install + +db_wait() { + if [[ "${PHPBB_DB_WAIT}" = "true" && "${PHPBB_DB_DRIVER}" != "sqlite3" && "${PHPBB_DB_DRIVER}" != "sqlite" ]]; then + until nc -z ${PHPBB_DB_HOST} ${PHPBB_DB_PORT}; do + echo "$(date) - waiting for database on ${PHPBB_DB_HOST}:${PHPBB_DB_PORT} to start before applying migrations" + sleep 3 + done + fi +} + +db_migrate() { + if [[ "${PHPBB_DB_AUTOMIGRATE}" = "true" && "${PHPBB_INSTALL}" != "true" ]]; then + echo "$(date) - applying migrations" + php bin/phpbbcli.php db:migrate + fi +} + +# Apache gets grumpy about PID files pre-existing +rm -f /run/apache2/httpd.pid + +db_wait && db_migrate && exec httpd -DFOREGROUND "$@" diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..db7a961 --- /dev/null +++ b/README.MD @@ -0,0 +1,173 @@ +# phpBB3 + +Very popular php forum engine. + +# How to use this image + +## Initial installation + +If you don't have a prepared phpBB database, you can use a standard phpBB +installer script, just run a temporary container with `PHPBB_INSTALL=true` +environment variable: + +```console +$ docker run -p 8000:80 --name phpbb-install -e PHPBB_INSTALL=true -d phpbb +``` + +Point your browser to the http://localhost:8000 to begin the +installation process. + +This image is bundled with SQLite3, MySQL and PostgresSQL database engines +support. Others can be added by creating custom Dockerfile. For MySQL and PostgresSQL +you can use standard container linking or use SQLite if you want a self +sufficient container. + +For SQLite3 set `Database server hostname or DSN` field to `/phpbb/sqlite/sqlite.db`. +This file will be created on a docker volume and outside of the webserver's document root +for security. Leave user name, password and database name fields blank. + +After the installation process is complete you can safely stop this container: + +```console +$ docker stop phpbb-install +``` + +## Starting + +You can start a container as follows: + + +```console +$ docker run --name phpbb -d phpbb +``` + +By default, it uses SQLite3 as a database backend, so you will need to supply +it with a database file. It's default path is `/phpbb/sqlite/sqlite.db`. + +You can import it from the temporary installation container above: + +```console +$ docker run --volumes-from phpbb-install --name phpbb phpbb +``` + +Or just copy it inside container if you have one from previous phpBB +installations: + +```console +$ docker cp /path/at/host/sqlite.db phpbb:/www/sqlite/sqlite.db +``` + +For other database engines you will need to pass credentials and driver type +using environment variables: + +```console +$ docker run --name phpbb \ + -e PHPBB_DB_DRIVER=mysqli \ + -e PHPBB_DB_HOST=dbmysql \ + -e PHPBB_DB_PORT=3306 \ + -e PHPBB_DB_NAME=phpbb \ + -e PHPBB_DB_USER=phpbb \ + -e PHPBB_DB_PASSWD=pass -d phpbb +``` + +## Environment variables + +This image utilises environment variables for basic configuration. Most of +them are passed directly to phpBB's `config.php` or to the startup script. + +### PHPBB_INSTALL +If set to `true`, container will start with an empty `config.php` file and +phpBB `/install/` directory intact. This will allow you to initilalize +a forum database upon fresh installation. + +### PHPBB_DB_DRIVER + +Selects a database driver. phpBB3 ships with following drivers: +- `mssql` - MS SQL Server +- `mysql` - MySQL via outdated php extension +- `mysqli` - MySQL via newer php extension +- `oracle` - Oracle +- `postgres` - PostgreSQL +- `sqlite` - SQLite 2 +- `sqlite3` - SQLite 3 + +This image is bundled with support of `sqlite3`, `mysqli` and `postgres` drivers. + +Default value: sqlite3 + +### PHPBB_DB_HOST + +Database hostname or ip address. + +For the SQLite3 driver sets database file path. + +Default value: /phpbb/sqlite/sqlite.db + +### PHPBB_DB_PORT + +Database port. + +### PHPBB_DB_NAME + +Supplies database name for phpBB3. + +### PHPBB_DB_USER + +Supplies a user name for phpBB3 database. + +### PHPBB_DB_PASSWD + +Supplies a user password for phpBB3 database. + +If you feel paranoid about providing your database password in an environment +variable, you can always ship it with a custom `config.php` file using volumes +or by extending this image. + +### PHPBB_DB_TABLE_PREFIX + +Table prefix for phpBB3 database. + +Default value: phpbb_ + +### PHPBB_DB_AUTOMIGRATE + +If set to `true`, instructs a container to run database migrations by +executing `bin/phpbbcli.php db:migrate` on every startup. + +If migrations fail, container will refuse to start. + +### PHPBB_DB_WAIT +If set to `true`, container will wait for database service to become available. +You will need to explicitly set `PHPBB_DB_HOST` and `PHPBB_DB_PORT` for this +to work. + +Use in conjunction with `PHPBB_DB_AUTOMIGRATE` to prevent running migrations +before database is ready. + +Won't work for SQLite database engine as it is always available. + +### PHPBB_DISPLAY_LOAD_TIME + +If set to `true`, phpBB will display page loading time, queries count and peak memory +usage at the bottom of the page. + +### PHPBB_DEBUG + +If set to `true`, enables phpBB debug mode. + +### PHPBB_DEBUG_CONTAINER + +## Volumes + +By default there are four volumes created for each container: +- /phpbb/sqlite +- /phpbb/www/files +- /phpbb/www/store +- /phpbb/www/images/avatars/upload + +# Additional configuration + +This image is based on a stock official Alpine image with apache2 and php5 +packages from the Alpine Linux repository, so you can drop their custom +configuration files to `/etc/apache2/conf.d` and `/etc/php5/conf.d`. + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1ad2c9b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '2' + +volumes: + phpbb-sqlite: {} + phpbb-files: {} + phpbb-store: {} + phpbb-avatars: {} + +services: + phpbb: + image: selim13/phpbb:3.1-apache + ports: + - '127.0.0.1:8000:80' + volumes: + - 'phpbb-sqlite:/phpbb/sqlite' + - 'phpbb-files:/phpbb/www/files' + - 'phpbb-store:/phpbb/www/store' + - 'phpbb-avatars:/phpbb/www/images/avatars/upload' + environment: + #PHPBB_INSTALL: 'true' + PHPBB_DB_AUTOMIGRATE: 'true'