Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add wikibase-lts and deploy-lts products #813

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_publish_image_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'wdqs-frontend@*'
- 'wdqs-proxy@*'
- 'wikibase@*'
- 'wikibase-lts@*'

permissions:
contents: write
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ on:
default: 'wikibase'
options:
- deploy
- deploy-lts
- elasticsearch
- quickstatements
- wdqs
- wdqs-frontend
- wdqs-proxy
- wikibase
- wikibase-lts
- All projects with unreleased changes
dry_run:
description: "Dry run, don't do it yet."
Expand Down
5 changes: 4 additions & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ else
)
fi

# transform TAGS to build args
IMAGE_NAME=$(jq -r '.name' package.json)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also just change the name in package.json? Without any code change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think this is not a good idea. I think we need to keep the -lts around until we finally publish to dockerhub only. Otherwise we need to change too many things, e.g. local image versioning vs latest only, how to identify images when pushed to/pulled from GHCR...


# Removes "-lts" from end of name if it exists.
# LTS products are released on Dockerhub on the main image name
IMAGE_NAME=${IMAGE_NAME%-lts}

# publish to Dockerhub
if [ "$PUBLISH" == true ]; then
# IMAGE_REGISTRY implies dockerhub if empty
Expand Down
18 changes: 18 additions & 0 deletions build/wikibase-lts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## 1.0.1 (2025-01-06)


### 🏡 Chore

- bump mediawiki to 1.42.3, bump extensions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- bump mediawiki to 1.42.3, bump extensions
- bump mediawiki to 1.39.10, bump extensions


## (from **[email protected]** (2024-10-09))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure whether we really want to include this information. Going forward, NX wouldn't generate it either. I think I would prefer just the list of changes since [email protected]


### 📖 Documentation

- Link to MediaWiki bundled extensions
Copy link
Contributor

@rti rti Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to spell it out once here: So whenever we change something on the wikibase product in the future, we always have to consider bringing it to lts too, right when we implement the change, review and merge it. In case we decide the change goes to latest and lts, we would apply the same change to both directories in the same PR, so NX would generate the same changelog entry for any of the both products whenever we release the next version.

I like this.

- Switch from `.example.com` to `.example`

### 🏡 Chore

- Removes re-installation of extensions already packaged with MediaWiki (ConfirmEdit, Nuke, Scribunto, SyntaxHighlight_Geshi, VisualEditor)
- Updates Wikibase EDTF extension
212 changes: 212 additions & 0 deletions build/wikibase-lts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Build configuration
ARG PHP_IMAGE_URL
ARG COMPOSER_IMAGE_URL

# ###########################################################################
# Based on https://github.com/wikimedia/mediawiki-docker/blob/1161796f04d6a6bcbec9fb4c67a8ce7248392403/1.41/apache/Dockerfile
# hadolint ignore=DL3006
FROM ${PHP_IMAGE_URL} as mediawiki

SHELL ["/bin/bash", "-exu", "-c"]

# System dependencies
RUN apt-get update; \
apt-get install -y --no-install-recommends \
git \
gettext-base \
librsvg2-bin \
imagemagick \
# Required for SyntaxHighlighting
python3 \
# Required for Scribunto
lua5.1 \
; \
rm -rf /var/lib/apt/lists/*

# Install the PHP extensions we need
# hadolint ignore=DL4006
RUN savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libicu-dev \
libonig-dev \
libbz2-dev=1.* \
; \
\
docker-php-ext-install -j "$(nproc)" \
bz2 \
calendar \
intl \
mbstring \
mysqli \
opcache \
; \
\
pecl install APCu-5.1.21; \
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/*

# Enable Short URLs
RUN a2enmod rewrite; \
{ \
echo "<Directory /var/www/html>"; \
echo " RewriteEngine On"; \
echo " RewriteCond %{REQUEST_FILENAME} !-f"; \
echo " RewriteCond %{REQUEST_FILENAME} !-d"; \
echo " RewriteRule ^ %{DOCUMENT_ROOT}/index.php [L]"; \
echo "</Directory>"; \
} > "$APACHE_CONFDIR/conf-available/short-url.conf"; \
a2enconf short-url

# Enable AllowEncodedSlashes for VisualEditor
RUN sed -i "s/<\/VirtualHost>/\tAllowEncodedSlashes NoDecode\n<\/VirtualHost>/" "$APACHE_CONFDIR/sites-available/000-default.conf"

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=60'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

# MediaWiki setup
WORKDIR /var/www/html
ARG MEDIAWIKI_VERSION
# hadolint ignore=DL4006
RUN set -eux; \
curl -fSL "https://releases.wikimedia.org/mediawiki/$(echo ${MEDIAWIKI_VERSION} | cut -d. -f1,2)/mediawiki-${MEDIAWIKI_VERSION}.tar.gz" -o mediawiki.tar.gz; \
tar -x --strip-components=1 -f mediawiki.tar.gz; \
rm -r mediawiki.tar.gz; \
install -d /var/log/mediawiki -o www-data

# ###########################################################################
# hadolint ignore=DL3006
FROM ${COMPOSER_IMAGE_URL} as composer

COPY --from=mediawiki --chown=nobody:nogroup /var/www/html /var/www/html
WORKDIR /var/www/html

COPY composer.local.json composer.local.json

# WORKAROUND for https://phabricator.wikimedia.org/T372458
# Take wikibase submodules from github as phabricator rate limits us
COPY --chown=nobody:nogroup --chmod=755 \
wikibase-submodules-from-github-instead-of-phabricator.patch \
/tmp/wikibase-submodules-from-github-instead-of-phabricator.patch
USER root
RUN apt-get update; \
apt-get install -y --no-install-recommends \
patch \
; \
rm -rf /var/lib/apt/lists/*
USER nobody

ARG WIKIBASE_COMMIT
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
RUN set -x; \
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikibase /var/www/html/extensions/Wikibase && \
git -C /var/www/html/extensions/Wikibase checkout ${WIKIBASE_COMMIT} && \
patch -d /var/www/html/extensions/Wikibase -Np1 </tmp/wikibase-submodules-from-github-instead-of-phabricator.patch && \
rm /tmp/wikibase-submodules-from-github-instead-of-phabricator.patch && \
git -C /var/www/html/extensions/Wikibase submodule update --init --recursive && \
rm -f /var/www/html/extensions/Wikibase/.travis.yml && \
find /var/www/html/extensions/Wikibase -name ".git*" -exec rm -rf {} +

ARG ALL_EXTENSIONS="Babel,cldr,CirrusSearch,Elastica,EntitySchema,OAuth,UniversalLanguageSelector,WikibaseCirrusSearch,WikibaseManifest"
ARG BABEL_COMMIT
ARG CLDR_COMMIT
ARG CIRRUSSEARCH_COMMIT
ARG ELASTICA_COMMIT
ARG ENTITYSCHEMA_COMMIT
ARG OAUTH_COMMIT
ARG UNIVERSALLANGUAGESELECTOR_COMMIT
ARG WIKIBASECIRRUSSEARCH_COMMIT
ARG WIKIBASEMANIFEST_COMMIT
ARG WIKIBASEEDTF_COMMIT
ARG WIKIBASELOCALMEDIA_COMMIT

SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
RUN set -x; \
IFS=',' read -ra EXTENSIONS <<< ${ALL_EXTENSIONS}; \
for EXTENSION in "${EXTENSIONS[@]}"; do \
rm -rf "extensions/${EXTENSION}"; \
git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/${EXTENSION}" "extensions/${EXTENSION}"; \
EXTENSION_COMMIT_VAR="${EXTENSION^^}_COMMIT"; \
EXTENSION_COMMIT="${!EXTENSION_COMMIT_VAR}"; \
git -C "extensions/${EXTENSION}" checkout "${EXTENSION_COMMIT}"; \
git -C "extensions/${EXTENSION}" submodule update --init --recursive; \
rm -rf "extensions/${EXTENSION}/.git*"; \
find "extensions/${EXTENSION}" -name ".git*" -exec rm -rf {} +; \
done; \
\
git clone "https://github.com/ProfessionalWiki/WikibaseEdtf.git" "extensions/WikibaseEdtf"; \
git -C "extensions/WikibaseEdtf" checkout "${WIKIBASEEDTF_COMMIT}"; \
rm -rf "extensions/WikibaseEdtf/.git*"; \
\
git clone "https://github.com/ProfessionalWiki/WikibaseLocalMedia.git" "extensions/WikibaseLocalMedia"; \
git -C "extensions/WikibaseLocalMedia" checkout "${WIKIBASELOCALMEDIA_COMMIT}"; \
rm -rf "extensions/WikibaseLocalMedia/.git*"; \
\
rm -rf vendor && \
rm -rf composer.lock && \
ls -la && pwd && \
composer install --no-dev -vv -n

# ###########################################################################
# hadolint ignore=DL3006
FROM mediawiki AS wikibase

LABEL org.opencontainers.image.source="https://github.com/wmde/wikibase-release-pipeline"

ARG GIT_CURRENT_REVISION

# Set error_reporting PHP.ini settings
# This is needed with PHP8+ and MediaWiki 1.39, as Wikibase contains deprecated code
# TODO: remove this and see how far we get
RUN { \
echo 'error_reporting = E_ALL ^ E_DEPRECATED'; \
} > /usr/local/etc/php/conf.d/error_reporting.ini

COPY --from=composer --chown=nobody:nogroup /var/www/html /var/www/html

# Remove world writable flag, in combination with sticky bit it breaks the w link
# https://github.com/wmde/wikibase-release-pipeline/commit/545c7aeec8d0245dc597d500afc934b40e656b3c
# Make upload path writable for the webserver user
RUN chmod o-w /var/www/html && \
ln -s /var/www/html/ /var/www/html/w && \
chown www-data /var/www/html/images -R

COPY wikibase-php.ini /usr/local/etc/php/conf.d/wikibase-php.ini
COPY entrypoint.sh /entrypoint.sh
COPY jobrunner-entrypoint.sh /jobrunner-entrypoint.sh
COPY htaccess /var/www/html/.htaccess
COPY LocalSettings.d LocalSettings.d
COPY default-extra-install.sh /default-extra-install.sh
COPY oauth.ini /templates/oauth.ini
COPY LocalSettings.wbs.php /templates/LocalSettings.wbs.php

ENV DB_NAME=my_wiki \
MW_WG_SITENAME=wikibase \
MW_WG_LANGUAGE_CODE=en \
ELASTICSEARCH_PORT=9200

ENTRYPOINT ["/bin/bash"]
CMD ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions build/wikibase-lts/LocalSettings.d/20_Wikibase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

# Wikibase Repository
wfLoadExtension( 'WikibaseRepository', "$IP/extensions/Wikibase/extension-repo.json" );
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";

# Wikibase Client
wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
11 changes: 11 additions & 0 deletions build/wikibase-lts/LocalSettings.d/30_WikibaseCirrusSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

if (isset($elasticsearchHost)) {
// https://www.mediawiki.org/wiki/Extension:WikibaseCirrusSearch
wfLoadExtension( 'WikibaseCirrusSearch' );

$wgCirrusSearchServers = [ $elasticsearchHost ];
$wgSearchType = 'CirrusSearch';
$wgCirrusSearchExtraIndexSettings['index.mapping.total_fields.limit'] = 5000;
$wgWBCSUseCirrus = true;
}
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/30_WikibaseEdtf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://github.com/ProfessionalWiki/WikibaseEdtf
## WikibaseEdtf Configuration
wfLoadExtension( 'WikibaseEdtf' );
6 changes: 6 additions & 0 deletions build/wikibase-lts/LocalSettings.d/30_WikibaseLocalMedia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// https://github.com/ProfessionalWiki/WikibaseLocalMedia
## WikibaseLocalMedia Configuration
## NOTE: WikibaseLocalMedia does currently not work in a client only setup.
wfLoadExtension( 'WikibaseLocalMedia' );
6 changes: 6 additions & 0 deletions build/wikibase-lts/LocalSettings.d/30_WikibaseManifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// https://www.mediawiki.org/wiki/Extension:WikibaseManifest

## WikibaseManifest Configuration
wfLoadExtension( 'WikibaseManifest' );
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_Babel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:Babel
## Babel Extension
wfLoadExtension( 'Babel' );
8 changes: 8 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_CirrusSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

if (isset($elasticsearchHost)) {
// https://www.mediawiki.org/wiki/Extension:CirrusSearch
wfLoadExtension( 'CirrusSearch' );

// See WikibaseCirrusSearch.php for further configuration
}
6 changes: 6 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_ConfirmEdit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// https://www.mediawiki.org/wiki/Extension:ConfirmEdit

## ConfirmEdit Configuration
wfLoadExtension( 'ConfirmEdit' );
8 changes: 8 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_Elastica.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

if (isset($elasticsearchHost)) {
// https://www.mediawiki.org/wiki/Extension:Elastica
wfLoadExtension( 'Elastica' );

// See WikibaseCirrusSearch.php for further configuration
}
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_EntitySchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:EntitySchema
## EntitySchema Configuration
wfLoadExtension( 'EntitySchema' );
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_Nuke.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:Nuke
## Nuke Configuration
wfLoadExtension( 'Nuke' );
8 changes: 8 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_OAuth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

## OAuth Extension
wfLoadExtension( 'OAuth' );
$wgGroupPermissions['sysop']['mwoauthproposeconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthmanageconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthviewprivate'] = true;
$wgGroupPermissions['sysop']['mwoauthupdateownconsumer'] = true;
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_Scribunto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
## Scribunto
wfLoadExtension( 'Scribunto' );
$wgScribuntoDefaultEngine = 'luastandalone';
$wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua5.1';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:SyntaxHighlight
## SyntaxHighlight
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:UniversalLanguageSelector
## UniversalLanguageSelector Extension
wfLoadExtension( 'UniversalLanguageSelector' );
10 changes: 10 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_VisualEditor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// https://www.mediawiki.org/wiki/Extension:VisualEditor
## VisualEditor Extension
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );

$wgVirtualRestConfig['modules']['parsoid'] = array(
'url' => 'http://localhost' . $wgScriptPath . '/rest.php',
);
5 changes: 5 additions & 0 deletions build/wikibase-lts/LocalSettings.d/40_cldr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// https://www.mediawiki.org/wiki/Extension:CLDR
## CLDR Extension
wfLoadExtension( 'cldr' );
Loading
Loading