From a269e5331b94ad804f47d99884d2d996446d0c75 Mon Sep 17 00:00:00 2001 From: Jim Tilander Date: Tue, 7 Jun 2016 11:16:08 -0700 Subject: [PATCH 1/2] Added installation of the LDAP module. Added installation of email dependencies. Added export of certificates store so you can add certs for you LDAP server. --- 1.24/Dockerfile | 32 ++++++++++++++++++++++++++------ 1.24/docker-entrypoint.sh | 10 ++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/1.24/Dockerfile b/1.24/Dockerfile index 72eff49..b4e44eb 100644 --- a/1.24/Dockerfile +++ b/1.24/Dockerfile @@ -1,8 +1,12 @@ FROM php:5.6-apache MAINTAINER Synctree App Force -ENV MEDIAWIKI_VERSION 1.24 -ENV MEDIAWIKI_FULL_VERSION 1.24.2 +ENV MEDIAWIKI_VERSION 1.26 +ENV MEDIAWIKI_FULL_VERSION 1.26.3 +ENV LDAP_VERSION REL1_26 + + +ENV DEBIAN_FRONTEND=noninteractive RUN set -x; \ apt-get update \ @@ -10,6 +14,9 @@ RUN set -x; \ g++ \ libicu52 \ libicu-dev \ + libldap2-dev \ + imagemagick \ + git \ && pecl install intl \ && echo extension=intl.so >> /usr/local/etc/php/conf.d/ext-intl.ini \ && apt-get purge -y --auto-remove g++ libicu-dev \ @@ -17,10 +24,8 @@ RUN set -x; \ RUN docker-php-ext-install mysqli opcache -RUN set -x; \ - apt-get update \ - && apt-get install -y --no-install-recommends imagemagick \ - && rm -rf /var/lib/apt/lists/* +RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ +RUN docker-php-ext-install ldap RUN a2enmod rewrite @@ -45,6 +50,21 @@ RUN MEDIAWIKI_DOWNLOAD_URL="https://releases.wikimedia.org/mediawiki/$MEDIAWIKI_ COPY apache/mediawiki.conf /etc/apache2/ RUN echo Include /etc/apache2/mediawiki.conf >> /etc/apache2/apache2.conf +RUN mkdir /var/tmp/stage && cd /var/tmp/stage && git clone -b $LDAP_VERSION https://github.com/wikimedia/mediawiki-extensions-LdapAuthentication.git +RUN mkdir /var/log/mediawiki + +# Install support for emailing. +RUN pear install Auth_SASL +RUN pear install net_smtp +RUN pear install mail + +# Read about the LDAP setup here: https://www.mediawiki.org/wiki/Extension:LDAP_Authentication/Requirements +# You basically need to stick your own .crt file in /usr/local/share/ca-certificates and restart the container. +# You can get the certificate by issuing "openssl s_client -showcerts -connect :636" +RUN echo "TLS_CACERTDIR /etc/ssl/certs" >> /etc/ldap/ldap.conf + +VOLUME ["/usr/local/share/ca-certificates"] + COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/1.24/docker-entrypoint.sh b/1.24/docker-entrypoint.sh index 988162c..d237200 100755 --- a/1.24/docker-entrypoint.sh +++ b/1.24/docker-entrypoint.sh @@ -2,6 +2,10 @@ set -e +# Always update the certificate store. +/usr/sbin/update-ca-certificates + + : ${MEDIAWIKI_SITE_NAME:=MediaWiki} if [ -z "$MEDIAWIKI_DB_HOST" -a -z "$MYSQL_PORT_3306_TCP" ]; then @@ -37,6 +41,12 @@ if ! [ -e index.php -a -e includes/DefaultSettings.php ]; then echo >&2 "Complete! MediaWiki has been successfully copied to $(pwd)" fi +if ! [ -d /var/www/html/extensions/LdapAuthentication ]; then + echo >&2 "Ldap extension not found, copying version $LDAP_VERSION to extensions..." + mkdir /var/www/html/extensions/LdapAuthentication + cp -r /var/tmp/stage/mediawiki-extensions-LdapAuthentication/* /var/www/html/extensions/LdapAuthentication +fi + : ${MEDIAWIKI_SHARED:=/var/www-shared/html} if [ -d "$MEDIAWIKI_SHARED" ]; then # If there is no LocalSettings.php but we have one under the shared From a04158a61ac400b42b31cf5127721effc68c6260 Mon Sep 17 00:00:00 2001 From: Jim Tilander Date: Tue, 7 Jun 2016 11:18:02 -0700 Subject: [PATCH 2/2] Moved some files around to reflect that we've moved to 1.26 Use source control to handle the actual branches / versions. --- 1.23/Dockerfile | 50 ----------- 1.23/docker-entrypoint.sh | 84 ------------------- 1.24/README.md | 39 --------- 1.24/apache/mediawiki.conf | 19 ----- 1.24/Dockerfile => Dockerfile | 0 1.23/README.md => README.md | 0 {1.23/apache => apache}/mediawiki.conf | 0 ...cker-entrypoint.sh => docker-entrypoint.sh | 0 8 files changed, 192 deletions(-) delete mode 100644 1.23/Dockerfile delete mode 100755 1.23/docker-entrypoint.sh delete mode 100644 1.24/README.md delete mode 100644 1.24/apache/mediawiki.conf rename 1.24/Dockerfile => Dockerfile (100%) rename 1.23/README.md => README.md (100%) rename {1.23/apache => apache}/mediawiki.conf (100%) rename 1.24/docker-entrypoint.sh => docker-entrypoint.sh (100%) diff --git a/1.23/Dockerfile b/1.23/Dockerfile deleted file mode 100644 index 7f45fb7..0000000 --- a/1.23/Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -FROM php:5.6-apache -MAINTAINER Synctree App Force - -ENV MEDIAWIKI_VERSION 1.23 -ENV MEDIAWIKI_FULL_VERSION 1.23.9 - -RUN set -x; \ - apt-get update \ - && apt-get install -y --no-install-recommends \ - g++ \ - libicu52 \ - libicu-dev \ - && pecl install intl \ - && echo extension=intl.so >> /usr/local/etc/php/conf.d/ext-intl.ini \ - && apt-get purge -y --auto-remove g++ libicu-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN docker-php-ext-install mysqli opcache - -RUN set -x; \ - apt-get update \ - && apt-get install -y --no-install-recommends imagemagick \ - && rm -rf /var/lib/apt/lists/* - -RUN a2enmod rewrite - -# https://www.mediawiki.org/keys/keys.txt -RUN gpg --keyserver pool.sks-keyservers.net --recv-keys \ - 441276E9CCD15F44F6D97D18C119E1A64D70938E \ - 41B2ABE817ADD3E52BDA946F72BC1C5D23107F8A \ - 162432D9E81C1C618B301EECEE1F663462D84F01 \ - 1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \ - 3CEF8262806D3F0B6BA1DBDD7956EE477F901A30 \ - 280DB7845A1DCAC92BB5A00A946B02565DC00AA7 - -RUN MEDIAWIKI_DOWNLOAD_URL="https://releases.wikimedia.org/mediawiki/$MEDIAWIKI_VERSION/mediawiki-$MEDIAWIKI_FULL_VERSION.tar.gz"; \ - set -x; \ - mkdir -p /usr/src/mediawiki \ - && curl -fSL "$MEDIAWIKI_DOWNLOAD_URL" -o mediawiki.tar.gz \ - && curl -fSL "${MEDIAWIKI_DOWNLOAD_URL}.sig" -o mediawiki.tar.gz.sig \ - && gpg --verify mediawiki.tar.gz.sig \ - && tar -xf mediawiki.tar.gz -C /usr/src/mediawiki --strip-components=1 - - -COPY apache/mediawiki.conf /etc/apache2/ -RUN echo Include /etc/apache2/mediawiki.conf >> /etc/apache2/apache2.conf - -COPY docker-entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] -CMD ["apache2-foreground"] diff --git a/1.23/docker-entrypoint.sh b/1.23/docker-entrypoint.sh deleted file mode 100755 index 988162c..0000000 --- a/1.23/docker-entrypoint.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -set -e - -: ${MEDIAWIKI_SITE_NAME:=MediaWiki} - -if [ -z "$MEDIAWIKI_DB_HOST" -a -z "$MYSQL_PORT_3306_TCP" ]; then - echo >&2 'error: missing MYSQL_PORT_3306_TCP environment variable' - echo >&2 ' Did you forget to --link some_mysql_container:mysql ?' - exit 1 -fi - -# if we're linked to MySQL, and we're using the root user, and our linked -# container has a default "root" password set up and passed through... :) -: ${MEDIAWIKI_DB_USER:=root} -if [ "$MEDIAWIKI_DB_USER" = 'root' ]; then - : ${MEDIAWIKI_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} -fi -: ${MEDIAWIKI_DB_NAME:=mediawiki} - -if [ -z "$MEDIAWIKI_DB_PASSWORD" ]; then - echo >&2 'error: missing required MEDIAWIKI_DB_PASSWORD environment variable' - echo >&2 ' Did you forget to -e MEDIAWIKI_DB_PASSWORD=... ?' - echo >&2 - echo >&2 ' (Also of interest might be MEDIAWIKI_DB_USER and MEDIAWIKI_DB_NAME.)' - exit 1 -fi - -if ! [ -e index.php -a -e includes/DefaultSettings.php ]; then - echo >&2 "MediaWiki not found in $(pwd) - copying now..." - - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi - tar cf - --one-file-system -C /usr/src/mediawiki . | tar xf - - echo >&2 "Complete! MediaWiki has been successfully copied to $(pwd)" -fi - -: ${MEDIAWIKI_SHARED:=/var/www-shared/html} -if [ -d "$MEDIAWIKI_SHARED" ]; then - # If there is no LocalSettings.php but we have one under the shared - # directory, symlink it - if [ -e "$MEDIAWIKI_SHARED/LocalSettings.php" -a ! -e LocalSettings.php ]; then - ln -s "$MEDIAWIKI_SHARED/LocalSettings.php" LocalSettings.php - fi - - # If the images directory only contains a README, then link it to - # $MEDIAWIKI_SHARED/images, creating the shared directory if necessary - if [ "$(ls images)" = "README" -a ! -L images ]; then - rm -fr images - mkdir -p "$MEDIAWIKI_SHARED/images" - ln -s "$MEDIAWIKI_SHARED/images" images - fi -fi - -: ${MEDIAWIKI_DB_HOST:=${MYSQL_PORT_3306_TCP#tcp://}} - -TERM=dumb php -- "$MEDIAWIKI_DB_HOST" "$MEDIAWIKI_DB_USER" "$MEDIAWIKI_DB_PASSWORD" "$MEDIAWIKI_DB_NAME" <<'EOPHP' -connect_error) { - file_put_contents('php://stderr', 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n"); - exit(1); -} - -if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) { - file_put_contents('php://stderr', 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n"); - $mysql->close(); - exit(1); -} - -$mysql->close(); -EOPHP - -chown -R www-data: . - -export MEDIAWIKI_SITE_NAME MEDIAWIKI_DB_HOST MEDIAWIKI_DB_USER MEDIAWIKI_DB_PASSWORD MEDIAWIKI_DB_NAME - -exec "$@" diff --git a/1.24/README.md b/1.24/README.md deleted file mode 100644 index 442d917..0000000 --- a/1.24/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# What is MediaWiki? - -MediaWiki is a free and open-source wiki app, used to power wiki websites such -as Wikipedia, Wiktionary and Commons, developed by the Wikimedia Foundation and -others. - -> [wikipedia.org/wiki/MediaWiki](https://en.wikipedia.org/wiki/MediaWiki) - -# How to use this image - - docker run --name some-mediawiki --link some-mysql:mysql -d synctree/mediawiki - -The following environment variables are also honored for configuring your -MediaWiki instance: - - - `-e MEDIAWIKI_DB_HOST=ADDR:PORT` (defaults to the address and port of the - linked mysql container) - - `-e MEDIAWIKI_DB_USER=...` (defaults to "root") - - `-e MEDIAWIKI_DB_PASSWORD=...` (defaults to the value of the - `MYSQL_ROOT_PASSWORD` environment variable from the linked mysql container) - - `-e MEDIAWIKI_DB_NAME=...` (defaults to "mediawiki") - -If the `MEDIAWIKI_DB_NAME` specified does not already exist in the given MySQL -container, it will be created automatically upon container startup, provided -that the `MEDIAWIKI_DB_USER` specified has the necessary permissions to create -it. - -To use with an external database server, use `MEDIAWIKI_DB_HOST` (along with -`MEDIAWIKI_DB_USER` and `MEDIAWIKI_DB_PASSWORD` if necessary): - - docker run --name some-mediawiki -e MEDIAWIKI_DB_HOST=10.0.0.1:3306 \ - -e MEDIAWIKI_DB_USER=app -e MEDIAWIKI_DB_PASSWORD=secure synctree/mediawiki - -If you'd like to be able to access the instance from the host without the -container's IP, standard port mappings can be used: - - docker run --name some-mediawiki --link some-mysql:mysql -p 8080:80 -d synctree/mediawiki - -Then, access it via `http://localhost:8080` or `http://host-ip:8080` in a browser. diff --git a/1.24/apache/mediawiki.conf b/1.24/apache/mediawiki.conf deleted file mode 100644 index f1b0450..0000000 --- a/1.24/apache/mediawiki.conf +++ /dev/null @@ -1,19 +0,0 @@ - - RewriteEngine On - RewriteBase / - RewriteRule ^index\.php$ - [L] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule . /index.php [L] - - - - # Ignore .htaccess files - AllowOverride None - - # Serve HTML as plaintext, don't execute SHTML - AddType text/plain .html .htm .shtml .php - - # Don't run arbitrary PHP code. - php_admin_flag engine off - diff --git a/1.24/Dockerfile b/Dockerfile similarity index 100% rename from 1.24/Dockerfile rename to Dockerfile diff --git a/1.23/README.md b/README.md similarity index 100% rename from 1.23/README.md rename to README.md diff --git a/1.23/apache/mediawiki.conf b/apache/mediawiki.conf similarity index 100% rename from 1.23/apache/mediawiki.conf rename to apache/mediawiki.conf diff --git a/1.24/docker-entrypoint.sh b/docker-entrypoint.sh similarity index 100% rename from 1.24/docker-entrypoint.sh rename to docker-entrypoint.sh