Docker MediaWiki Server: Difference between revisions

Jump to navigation Jump to search
Updated to reflect 1.39.4 is the latest supported LTS version of MediaWiki
mNo edit summary
(Updated to reflect 1.39.4 is the latest supported LTS version of MediaWiki)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Category: How to]]
[[Category:How to]]
[[Category:Software]]
[[Category:Software]]
= Docker MediaWiki Server =
Notes and configuration files for setting up MediaWiki in a dockerized environment.
Notes and configuration files for setting up MediaWiki in a dockerized environment.


Line 30: Line 28:
===MediaWiki===
===MediaWiki===
Copy the following to '''/srv/wiki/docker-compose.yml'''
Copy the following to '''/srv/wiki/docker-compose.yml'''
 
<syntaxhighlight lang="yaml">
  version: '3'
version: '3'
  services:
services:
    web:
  web:
      image: mediawiki
    image: mediawiki
      build: build/.
    build: build/.
      container_name: wiki
    container_name: wiki
      depends_on:  
    depends_on:  
        - database
      - database
          ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
      ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
          #- parsoid
      #- parsoid
      restart: always
    restart: always
      ports:
    ports:
        - 80:80
      - 80:80
      links:
    links:
        - database
      - database
      volumes:
    volumes:
        - /srv/wiki/html/images:/var/www/html/images
      - /srv/wiki/html/images:/var/www/html/images
        ## TODO: remove the # below AFTER you have downloaded the LocalSettings.php file
      ## TODO: remove the # below AFTER you have downloaded the LocalSettings.php file
        #- /srv/wiki/LocalSettings.php:/var/www/html/LocalSettings.php
      #- /srv/wiki/LocalSettings.php:/var/www/html/LocalSettings.php
    database:
  database:
      image: mariadb
    image: mariadb
      container_name: db
    container_name: db
      restart: always
    restart: always
      environment:
    environment:
        MYSQL_DATABASE: mediawiki
      MYSQL_DATABASE: mediawiki
        ## TODO: Change the password below
      ## TODO: Change the password below
        MYSQL_USER: wikiuser
      MYSQL_USER: wikiuser
        ## TODO: Change the password below
      ## TODO: Change the password below
        MYSQL_PASSWORD: wiki
      MYSQL_PASSWORD: wiki
        MYSQL_ROOT_PASSWORD: changeme
      MYSQL_ROOT_PASSWORD: changeme
      volumes:
    volumes:
        - /srv/wiki/db:/var/lib/mysql
      - /srv/wiki/db:/var/lib/mysql
     
 
      ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
  ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
      #parsoid:
  #parsoid:
      #  image: thenets/parsoid:0.10
  #  image: thenets/parsoid:0.10
      #  container_name: parsoid
  #  container_name: parsoid
      #  restart: always
  #  restart: always
      #  environment:
  #  environment:
      #  - PARSOID_NUM_WORKERS=0
  #  - PARSOID_NUM_WORKERS=0
      #    - PARSOID_DOMAIN_wiki=http://web/api.php
  #    - PARSOID_DOMAIN_wiki=http://web/api.php
      #  networks:
</syntaxhighlight>
      #    - default


==Internet==
==Internet==
Line 79: Line 76:


===NGINX-Proxy===
===NGINX-Proxy===
Copy the following to '''/srv/nginx-proxy/docker-compose.yml'''
*Copy the following to '''/srv/nginx-proxy/docker-compose.yml'''
<syntaxhighlight lang="yaml">
version: '2'
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    environment:
      - "HTTPS_METHOD=noredirect"
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
    ports:
      - "80:80"
      - "443:443"
    restart: always
    volumes:
      - "./data/etc/certs:/etc/nginx/certs"
      - "./data/etc/nginx/vhost.d:/etc/nginx/vhost.d"
      - "./data/etc/nginx/htpasswd:/etc/nginx/htpasswd"
      - "./data/etc/nginx/html:/usr/share/nginx/html"
      - "./data/etc/nginx/conf.d:/etc/nginx/conf.d"
      - "/var/run/docker.sock:/tmp/docker.sock:ro"


    version: '2'
  letsencrypt:
     services:
     image: jrcs/letsencrypt-nginx-proxy-companion
      nginx-proxy:
    environment:
        image: jwilder/nginx-proxy
    ### ToDo: Change to your e-mail address
        container_name: nginx-proxy
    #      - DEFAULT_EMAIL=admin@demo.io
        environment:
      - NGINX_PROXY_CONTAINER=nginx-proxy
          - "HTTPS_METHOD=noredirect"
    volumes_from:
        labels:
      - nginx-proxy
          - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
    volumes:
        ports:
      - /var/run/docker.sock:/var/run/docker.sock:ro
          - "80:80"
      - ./data/etc/certs:/etc/nginx/certs:rw
          - "443:443"
    restart: always
        restart: always
 
        volumes:
networks:
          - "./data/etc/certs:/etc/nginx/certs"
  default:
          - "./data/etc/nginx/vhost.d:/etc/nginx/vhost.d"
    external:
          - "./data/etc/nginx/htpasswd:/etc/nginx/htpasswd"
      name: nginx-proxy
          - "./data/etc/nginx/html:/usr/share/nginx/html"
</syntaxhighlight>
          - "/var/run/docker.sock:/tmp/docker.sock:ro"
 
   
*Copy the following to '''/srv/nginx-proxy/data/etc/nginx/conf.d/proxy-settings.conf'''
      letsencrypt:
<syntaxhighlight lang="text">
        image: jrcs/letsencrypt-nginx-proxy-companion
proxy_connect_timeout      300;
        environment:
proxy_send_timeout          300;
        ### ToDo: Change to your e-mail address
proxy_read_timeout          30m;
        #      - DEFAULT_EMAIL=admin@demo.io
send_timeout                300;
          - NGINX_PROXY_CONTAINER=nginx-proxy
</syntaxhighlight>
        volumes_from:
 
          - nginx-proxy
Note: Add the following line to the file above for large file upload issues:
        volumes:
<syntaxhighlight lang="text">
          - /var/run/docker.sock:/var/run/docker.sock:ro
client_max_body_size        5000m;
          - ./data/etc/certs:/etc/nginx/certs:rw
</syntaxhighlight>
        restart: always
You will need to adjust the size to a value suitable for your environment.
   
    networks:
      default:
        external:
          name: nginx-proxy


====Create docker network====
====Create docker network====
Line 125: Line 138:
===MediaWiki===
===MediaWiki===
Copy the following to '''/srv/wiki/docker-compose.yml'''
Copy the following to '''/srv/wiki/docker-compose.yml'''
 
<syntaxhighlight lang="yaml">
    version: '3'
version: '3'
    services:
services:
      web:
  web:
        image: mediawiki
    image: mediawiki
        build: build/.
    build: build/.
        container_name: wiki
    container_name: wiki
        depends_on:  
    depends_on:  
          - database
      - database
        ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
    ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
        #  - parsoid
    #  - parsoid
        restart: always
    restart: always
        environment:
    environment:
          ## TODO: CHANGE VIRTUAL_HOST, LETSENCRYPT_HOST, and LETSENCRYPT_EMAIL TO YOUR OWN
      ## TODO: CHANGE VIRTUAL_HOST, LETSENCRYPT_HOST, and LETSENCRYPT_EMAIL TO YOUR OWN
          - VIRTUAL_HOST=wiki.example.com
      - VIRTUAL_HOST=wiki.example.com
          - HTTPS_METHOD=nohttp
      - HTTPS_METHOD=nohttp
          - LETSENCRYPT_HOST=wiki.example.com
      - LETSENCRYPT_HOST=wiki.example.com
          - LETSENCRYPT_EMAIL=nobody@example.com
      - LETSENCRYPT_EMAIL=nobody@example.com
        links:
    links:
          - database
      - database
        volumes:
    volumes:
          - /srv/wiki/html/images:/var/www/html/images
      - /srv/wiki/html/images:/var/www/html/images
          ## TODO: remove the # below AFTER you have downloaded the LocalSettings.php file
      ## TODO: remove the # below AFTER you have downloaded the LocalSettings.php file
          #- /srv/wiki/LocalSettings.php:/var/www/html/LocalSettings.php
      #- /srv/wiki/LocalSettings.php:/var/www/html/LocalSettings.php
        networks:
    networks:
          - default
      - default
          - nginx-proxy
      - nginx-proxy
   
 
      database:
  database:
        image: mariadb
    image: mariadb
        container_name: db
    container_name: db
        restart: always
    restart: always
        environment:
    environment:
          MYSQL_DATABASE: mediawiki
      MYSQL_DATABASE: mediawiki
          MYSQL_USER: wikiuser
      MYSQL_USER: wikiuser
          ## TODO: Change the password below
      ## TODO: Change the password below
          MYSQL_PASSWORD: wiki
      MYSQL_PASSWORD: wiki
          ## TODO: Change the password below
      ## TODO: Change the password below
          MYSQL_ROOT_PASSWORD: changeme
      MYSQL_ROOT_PASSWORD: changeme
        volumes:
    volumes:
          - /srv/wiki/db:/var/lib/mysql
      - /srv/wiki/db:/var/lib/mysql
        networks:
    networks:
          - default
      - default
      ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
  ## parsoid is bundled as part of 1.35+, only uncomment if using an older version
      #parsoid:
  #parsoid:
      #  image: thenets/parsoid:0.10
  #  image: thenets/parsoid:0.10
      #  container_name: parsoid
  #  container_name: parsoid
      #  restart: always
  #  restart: always
      #  environment:
  #  environment:
      #    - PARSOID_NUM_WORKERS=0
  #    - PARSOID_NUM_WORKERS=0
      #    - PARSOID_DOMAIN_wiki=http://web/api.php
  #    - PARSOID_DOMAIN_wiki=http://web/api.php
      #  networks:  
  #  networks:  
      #    - default
  #    - default
      
      
    networks:
networks:
      nginx-proxy:
  nginx-proxy:
        external:
    external:
          name: nginx-proxy
      name: nginx-proxy
</syntaxhighlight>


=Mediawiki Docker Image=
=Mediawiki Docker Image=
Line 201: Line 215:


Note: You can change the version of the MediaWiki docker image used by changing the FROM line.
Note: You can change the version of the MediaWiki docker image used by changing the FROM line.
 
<syntaxhighlight lang="dockerfile">
    FROM mediawiki:1.35.3
FROM mediawiki:1.39.4
    COPY ./extensions /var/www/html/extensions
COPY ./extensions /var/www/html/extensions
</syntaxhighlight>


==== Advanced ====
==== Advanced ====
Note: You can change the version installed by changing:
Note: You can change the version installed by changing:
* '''ENV MEDIAWIKI_MAJOR_VERSION 1.36'''
* '''ENV MEDIAWIKI_MAJOR_VERSION 1.41'''
* '''ENV MEDIAWIKI_VERSION 1.36.1'''
* '''ENV MEDIAWIKI_VERSION 1.41.1'''
* '''ENV MW_VERSION REL1_36'''
* '''ENV MW_VERSION REL1_41'''


To change to version 1.35 (LTS until 2023) you can substitute 1.35, 1.35.3, and REL1_35 for the values above.
To change to version 1.39 (LTS until Nov 2025) you can substitute 1.39, 1.39.4, and REL1_39 for the values above.


Copy the following to '''/srv/wiki/build/Dockerfile'''
Copy the following to '''/srv/wiki/build/Dockerfile'''
<syntaxhighlight lang="dockerfile">
FROM php:7.4-apache
COPY --from=composer /usr/bin/composer /usr/bin/composer
# System dependencies
RUN set -eux; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
git \
librsvg2-bin \
imagemagick \
# Required for SyntaxHighlighting
python3 \
; \
rm -rf /var/lib/apt/lists/*
# Install the PHP extensions we need
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libicu-dev \
libonig-dev \
; \
\
docker-php-ext-install -j "$(nproc)" \
intl \
mbstring \
mysqli \
opcache \
; \
\
pecl install APCu-5.1.20; \
docker-php-ext-enable \
apcu \
; \
rm -r /tmp/pear; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { print $3 }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*


    FROM php:7.4-apache
# Enable Short URLs
   
RUN set -eux; \
    COPY --from=composer /usr/bin/composer /usr/bin/composer
a2enmod rewrite; \
   
{ \
    # System dependencies
echo "<Directory /var/www/html>"; \
    RUN set -eux; \
echo "  RewriteEngine On"; \
    \
echo "  RewriteCond %{REQUEST_FILENAME} !-f"; \
    apt-get update; \
echo "  RewriteCond %{REQUEST_FILENAME} !-d"; \
    apt-get install -y --no-install-recommends \
echo "  RewriteRule ^ %{DOCUMENT_ROOT}/index.php [L]"; \
    git \
echo "</Directory>"; \
    librsvg2-bin \
} > "$APACHE_CONFDIR/conf-available/short-url.conf"; \
    imagemagick \
a2enconf short-url
    # Required for SyntaxHighlighting
 
    python3 \
# Enable AllowEncodedSlashes for VisualEditor
    ; \
RUN sed -i "s/<\/VirtualHost>/\tAllowEncodedSlashes NoDecode\n<\/VirtualHost>/" "$APACHE_CONFDIR/sites-available/000-default.conf"
    rm -rf /var/lib/apt/lists/*
 
   
# set recommended PHP.ini settings
    # Install the PHP extensions we need
# see https://secure.php.net/manual/en/opcache.installation.php
    RUN set -eux; \
RUN { \
    \
echo 'opcache.memory_consumption=128'; \
    savedAptMark="$(apt-mark showmanual)"; \
echo 'opcache.interned_strings_buffer=8'; \
    \
echo 'opcache.max_accelerated_files=4000'; \
    apt-get update; \
echo 'opcache.revalidate_freq=60'; \
    apt-get install -y --no-install-recommends \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
    libicu-dev \
 
    libonig-dev \
# SQLite Directory Setup
    ; \
RUN set -eux; \
    \
mkdir -p /var/www/data; \
    docker-php-ext-install -j "$(nproc)" \
chown -R www-data:www-data /var/www/data
    intl \
 
    mbstring \
# Version
    mysqli \
ENV MEDIAWIKI_MAJOR_VERSION 1.39
    opcache \
ENV MEDIAWIKI_VERSION 1.39.4
    ; \
ENV MW_VERSION=REL1_39
    \
 
    pecl install APCu-5.1.20; \
# Home folder location
    docker-php-ext-enable \
ENV MW_HOME=/var/www/html
    apcu \
 
    ; \
 
    rm -r /tmp/pear; \
# MediaWiki setup
    \
RUN set -eux; \
    # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
fetchDeps=" \
    apt-mark auto '.*' > /dev/null; \
gnupg \
    apt-mark manual $savedAptMark; \
dirmngr \
    ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
"; \
    | awk '/=>/ { print $3 }' \
apt-get update; \
    | sort -u \
apt-get install -y --no-install-recommends $fetchDeps; \
    | xargs -r dpkg-query -S \
\
    | cut -d: -f1 \
curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz" -o mediawiki.tar.gz; \
    | sort -u \
curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz.sig" -o mediawiki.tar.gz.sig; \
    | xargs -rt apt-mark manual; \
export GNUPGHOME="$(mktemp -d)"; \
    \
# gpg key from https://www.mediawiki.org/keys/keys.txt
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys \
    rm -rf /var/lib/apt/lists/*
D7D6767D135A514BEB86E9BA75682B08E8A3FEC4 \
   
441276E9CCD15F44F6D97D18C119E1A64D70938E \
    # Enable Short URLs
F7F780D82EBFB8A56556E7EE82403E59F9F8CD79 \
    RUN set -eux; \
1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \
    a2enmod rewrite; \
; \
    { \
gpg --batch --verify mediawiki.tar.gz.sig mediawiki.tar.gz; \
    echo "<Directory /var/www/html>"; \
tar -x --strip-components=1 -f mediawiki.tar.gz; \
    echo "  RewriteEngine On"; \
gpgconf --kill all; \
    echo " RewriteCond %{REQUEST_FILENAME} !-f"; \
rm -r "$GNUPGHOME" mediawiki.tar.gz.sig mediawiki.tar.gz; \
    echo "  RewriteCond %{REQUEST_FILENAME} !-d"; \
chown -R www-data:www-data extensions skins cache images; \
    echo "  RewriteRule ^ %{DOCUMENT_ROOT}/index.php [L]"; \
  \
    echo "</Directory>"; \
  apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
    } > "$APACHE_CONFDIR/conf-available/short-url.conf"; \
  rm -rf /var/lib/apt/lists/*
    a2enconf short-url
 
   
RUN set -eux; \
    # Enable AllowEncodedSlashes for VisualEditor
        apt update; \
    RUN sed -i "s/<\/VirtualHost>/\tAllowEncodedSlashes NoDecode\n<\/VirtualHost>/" "$APACHE_CONFDIR/sites-available/000-default.conf"
        apt install -y --no-install-recommends \
   
            unzip
    # set recommended PHP.ini settings
 
    # see https://secure.php.net/manual/en/opcache.installation.php
##### Commonly used extensions
    RUN { \
RUN set -x; \
    echo 'opcache.memory_consumption=128'; \
     cd $MW_HOME/extensions \
    echo 'opcache.interned_strings_buffer=8'; \
     && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Echo \
    echo 'opcache.max_accelerated_files=4000'; \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Thanks \
    echo 'opcache.revalidate_freq=60'; \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CheckUser
    } > /usr/local/etc/php/conf.d/opcache-recommended.ini
 
   
# Flow extension
    # SQLite Directory Setup
RUN set -x; \
    RUN set -eux; \
    cd $MW_HOME/extensions \
    mkdir -p /var/www/data; \
     && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Flow \
    chown -R www-data:www-data /var/www/data
    && cd Flow \
   
    && composer install --no-dev \
    # Version
    && cd ..
    ENV MEDIAWIKI_MAJOR_VERSION 1.35
 
    ENV MEDIAWIKI_VERSION 1.35.3
### MediaWiki Language Extension Bundle
    ENV MW_VERSION=REL1_35
# Translate
   
RUN set -x; \
    # Home folder location
    cd $MW_HOME/extensions \
     ENV MW_HOME=/var/www/html
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Babel \
      
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/cldr \
   
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CleanChanges \
    # MediaWiki setup
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UniversalLanguageSelector
    RUN set -eux; \
 
    fetchDeps=" \
##### ElasticSearch extensions
    gnupg \
RUN set -x; \
    dirmngr \
    cd $MW_HOME/extensions \
    "; \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CirrusSearch \
    apt-get update; \
     && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Elastica \
    apt-get install -y --no-install-recommends $fetchDeps; \
    && cd Elastica \
    \
    && composer install --no-dev \
    curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz" -o mediawiki.tar.gz; \
    && cd ..
    curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz.sig" -o mediawiki.tar.gz.sig; \
 
    export GNUPGHOME="$(mktemp -d)"; \
##### MobileFrontend extension
     # gpg key from https://www.mediawiki.org/keys/keys.txt
RUN set -x; \
    gpg --batch --keyserver keyserver.ubuntu.com --recv-keys \
    cd $MW_HOME/extensions \
    D7D6767D135A514BEB86E9BA75682B08E8A3FEC4 \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MobileFrontend
    441276E9CCD15F44F6D97D18C119E1A64D70938E \
 
    F7F780D82EBFB8A56556E7EE82403E59F9F8CD79 \
##### ElectronPdfService extension
    1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \
RUN set -x; \
    ; \
    cd $MW_HOME/extensions \
    gpg --batch --verify mediawiki.tar.gz.sig mediawiki.tar.gz; \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ElectronPdfService
    tar -x --strip-components=1 -f mediawiki.tar.gz; \
 
    gpgconf --kill all; \
##### ConfirmAccount, UploadWizard
    rm -r "$GNUPGHOME" mediawiki.tar.gz.sig mediawiki.tar.gz; \
RUN set -x; \
    chown -R www-data:www-data extensions skins cache images; \
    cd $MW_HOME/extensions \
      \
     && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ConfirmAccount \
      apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
    && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UploadWizard
      rm -rf /var/lib/apt/lists/*
 
   
 
    RUN set -eux; \
#### Add AutoSitemap extension ** disable if wiki is not reacahble from Internet!
            apt update; \
RUN set -x; \
            apt install -y --no-install-recommends \
    cd $MW_HOME/extensions \
                unzip
    && git clone --depth 1 https://github.com/dolfinus/AutoSitemap.git
      
 
    ##### Commonly used extensions
# Copy any other extenions from the ./build/extensions folder
    RUN set -x; \
COPY ./extensions $MW_HOME/extensions
        cd $MW_HOME/extensions \
 
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Echo \
CMD ["apache2-foreground"]
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Thanks \
</syntaxhighlight>
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CheckUser
   
    # Flow extension
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Flow \
        && cd Flow \
        && composer install --no-dev \
        && cd ..
      
    ### MediaWiki Language Extension Bundle
    # Translate
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Babel \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/cldr \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CleanChanges \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UniversalLanguageSelector
   
    ##### ElasticSearch extensions
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CirrusSearch \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Elastica \
        && cd Elastica \
        && composer install --no-dev \
        && cd ..
   
    ##### MobileFrontend extension
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MobileFrontend
   
    ##### ElectronPdfService extension
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ElectronPdfService
   
    ##### ConfirmAccount, UploadWizard
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ConfirmAccount \
        && git clone --depth 1 -b $MW_VERSION https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UploadWizard
   
   
    #### Add AutoSitemap extension ** disable if wiki is not reacahble from Internet!
    RUN set -x; \
        cd $MW_HOME/extensions \
        && git clone --depth 1 https://github.com/dolfinus/AutoSitemap.git
   
    # Copy any other extenions from the ./build/extensions folder
    COPY ./extensions $MW_HOME/extensions
   
    CMD ["apache2-foreground"]


=Running=
=Running=
Line 422: Line 438:
* Run '''''docker-compose up -d'''''
* Run '''''docker-compose up -d'''''
* Wait a minute then navigate to your wiki with https://<hostname/IP> for Intranet or https://<FQDN> for Internet.
* Wait a minute then navigate to your wiki with https://<hostname/IP> for Intranet or https://<FQDN> for Internet.
===Private IPs===
Mediawiki will only use the IP presented by the NGINX Proxy server (which will not be the client's real IP).  To have Mediawiki trust the X-Forwarded-For (and record them), add the following to the LocalSettings.php file:
<syntaxhighlight lang="php">
# Use X-ForwardedFor instead for Real IP
$wgUseCdn = true;
$wgCdnServersNoPurge = [];
$wgCdnServersNoPurge[] = "172.18.0.0/24";
</syntaxhighlight>
Change the '''172.18.0.0/24''' to the subnet your container is using for talking to the NGINX Proxy.
Reference: https://www.mediawiki.org/wiki/Manual:$wgUsePrivateIPs


=Misc=
=Misc=
Line 448: Line 476:


Add this to your '''LocalSettings.php''' file:
Add this to your '''LocalSettings.php''' file:
 
<syntaxhighlight lang="php>
  $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',
      'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',
    'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',
      'pptx', 'ps', 'odt', 'ods', 'odp', 'odg'
    'pptx', 'ps', 'odt', 'ods', 'odp', 'odg'
  );
);
</syntaxhighlight>


===Increase file upload size===
===Increase file upload size===
Line 459: Line 488:


* Add this to your '''LocalSettings.php''' file to allow uploading of 2G files:
* Add this to your '''LocalSettings.php''' file to allow uploading of 2G files:
 
<syntaxhighlight lang="php>
  $wgUploadSizeWarning = 2147483647;
$wgUploadSizeWarning = 2147483647;
  $wgMaxUploadSize = 2147483647;
$wgMaxUploadSize = 2147483647;
 
</syntaxhighlight>
* Then create '''/srv/wiki/uploads.ini''' with the following:
* Then create '''/srv/wiki/uploads.ini''' with the following:
 
<syntaxhighlight lang="php>
  upload_max_filesize = 2048M
upload_max_filesize = 2048M
  post_max_size = 2048M
post_max_size = 2048M
  max_execution_time = 7200
max_execution_time = 7200
  max_file_uploads = 1000
max_file_uploads = 1000
 
</syntaxhighlight>
* Add the following line to the '''/srv/wiki/docker-compose.yml''' file under volumes
* Add the following line to the '''/srv/wiki/docker-compose.yml''' file under volumes


   - /srv/wiki/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:ro
   - /srv/wiki/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:ro

Navigation menu