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

add dockerized wiki configuration #117

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6b557fd
add dockerized wiki configuration
Flipez Aug 8, 2024
6aae740
expose port
Basma1912 Aug 19, 2024
b9de7b1
expose port
Basma1912 Aug 19, 2024
5f46497
revert_expose port
Basma1912 Aug 19, 2024
d9862d0
revert_expose port
Basma1912 Aug 19, 2024
b866083
revert_expose port
Basma1912 Aug 19, 2024
61fc17a
revert_expose port
Basma1912 Aug 19, 2024
6f3192e
uncomment_bugzilla_line
Basma1912 Aug 20, 2024
3b08cb0
comment_bugzilla_line
Basma1912 Aug 20, 2024
89e53b3
Pull in Bugzilla.
cass-moz Aug 20, 2024
78250c2
add_copy_LOCALsettings.php line
Basma1912 Aug 21, 2024
55890a4
revert_back
Basma1912 Aug 21, 2024
1067f9f
Pull in localsettings.
cass-moz Aug 21, 2024
51b00b2
Add support for readonly.
cass-moz Aug 22, 2024
78aebd6
Support a upgrade mode.
cass-moz Aug 27, 2024
533ed35
prep for 1.35 upgrade.
cass-moz Sep 5, 2024
31e1140
small fixes in settings.
cass-moz Sep 5, 2024
965a9a0
remove cache options.
cass-moz Sep 10, 2024
298d202
bump to 39 for testing
cass-moz Sep 10, 2024
0f2c8f3
setup paths.
cass-moz Sep 10, 2024
fd48c91
fix cache
cass-moz Sep 11, 2024
43ee1b5
add tmp dir.
cass-moz Sep 12, 2024
6a7d39d
remove tmp and use default
cass-moz Sep 12, 2024
3ead49d
another try
cass-moz Sep 12, 2024
c16a63c
disable createaccount for testing and for confirmaccount.
cass-moz Sep 16, 2024
c704e10
change how upgrade mode works.
cass-moz Sep 16, 2024
e15e6e2
fix some plugin loads and try another skin for mobile.
cass-moz Sep 17, 2024
08e0173
disable page bounce.
cass-moz Sep 18, 2024
d8a6dc2
drop semantic-mediawiki
cass-moz Oct 7, 2024
6fa48ec
remove unneeded steps from readme.
cass-moz Oct 18, 2024
93c4ca4
switch to questy captcha.
cass-moz Oct 18, 2024
c04968e
Add SendGrid.
cass-moz Dec 2, 2024
61b8833
Set 1.35.
cass-moz Dec 3, 2024
c0f089b
Set to 1.39.
cass-moz Dec 3, 2024
846ce59
fix(docker): Add php-gd extension
Flipez Dec 4, 2024
40a1daf
Merge pull request #118 from mozilla/add-php-gd
Flipez Dec 4, 2024
a6f572a
Remove 1.35 config skip.
cass-moz Dec 4, 2024
34051f1
Disable warnings and notices for php.
cass-moz Dec 6, 2024
e507eb9
Move to php.ini file.
cass-moz Dec 6, 2024
a100c35
Add deprecated to phpini.
cass-moz Dec 6, 2024
77aebc8
Set writeapi to true for all so login works.
cass-moz Dec 12, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ nubis/terraform/.terraform
nubis/terraform/terraform.tfvars
nubis/builder/artifacts/*-dev/
nubis/builder/artifacts/AMIs.json

# Database dump for local development
wiki.sql*
40 changes: 40 additions & 0 deletions gcp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Ensure both post 1. numbers match here.
FROM docker.io/mediawiki:1.39
ENV MWIKI_VER=39
WORKDIR /var/www/html/

ARG UID=10001
ARG GID=10001

RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg unzip zlib1g-dev libpng-dev
RUN docker-php-ext-install gd

# Prepare for nonroot user
RUN groupadd -g $GID app; \
useradd -g $GID -u $UID -m -s /usr/sbin/nologin app; \
chown -R app:app /var/www/html/

USER app

RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmAccount /var/www/html/extensions/ConfirmAccount
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/LabeledSectionTransclusion /var/www/html/extensions/LabeledSectionTransclusion
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/TimedMediaHandler /var/www/html/extensions/TimedMediaHandler
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/RSS /var/www/html/extensions/RSS
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/PageForms /var/www/html/extensions/PageForms
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/UrlGetParameters /var/www/html/extensions/UrlGetParameters
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/NoTitle /var/www/html/extensions/NoTitle
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/Widgets /var/www/html/extensions/Widgets
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend /var/www/html/extensions/MobileFrontend
RUN git clone --depth 1 --single-branch --branch REL1_${MWIKI_VER} https://gerrit.wikimedia.org/r/mediawiki/extensions/SendGrid /var/www/html/extensions/SendGrid
RUN git clone --depth 1 --single-branch --branch main https://github.com/mozilla/mediawiki-bugzilla.git /var/www/html/extensions/Bugzilla

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');"

COPY composer.local.json /var/www/html/composer.local.json
COPY ports.conf /etc/apache2/ports.conf
COPY LocalSettings.php /var/www/html/LocalSettings.php
COPY php.ini /usr/local/etc/php/php.ini
RUN php composer.phar update --no-dev
550 changes: 550 additions & 0 deletions gcp/LocalSettings.php

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions gcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# wikimo test

## "Runbook"

Use `docker compose up --build mediawiki` after changing the version in `Dockerfile`.

To migrate the db dump to the latest version use the following path:

- switch the version in `Dockerfile` to `mediawiki:1.35` and update MWIKI_VER to match the point release number.
- Set "wikimedia/at-ease": "v2.1.0" to "wikimedia/at-ease": "v2.0.0"
- Run `docker compose exec mediawiki php maintenance/update.php`

- switch the version in `Dockerfile` to `mediawiki:1.39` and update MWIKI_VER to match the point release number.
- Set "wikimedia/at-ease": "v2.0.0" to "wikimedia/at-ease": "v2.1.0"
- Run `docker compose exec mediawiki php maintenance/update.php`

### Notes
- switch the version in `Dockerfile` to `mediawiki:1.xx` and update MWIKI_VER to match the point release number.
- Run `docker-compose exec mediawiki php maintenance/run.php update.php`

## Cleanup Scripts
Scripts that could be run on >=1.27
```shell
compose exec mediawiki php maintenance/deleteArchivedRevisions.php --delete
compose exec mediawiki php maintenance/removeUnusedAccounts.php --delete
```

## Migration Plan
1. Put the AWS Wiki into maintenance.
2. Dump the DB.
3. Import DB and images into GCP environment.
4. Deploy a 1.35 build to GCP.
5. Run `php maintenance/update.php` with 1.35.
6. Deploy a 1.39 build to GCP
7. Check GCP version of wiki.
8. Update DNS to point to GCP Wiki.
9. Remove maintenance mode on GCP Wiki.
10. Clean up AWS Wiki (and optionally Nubis).
19 changes: 19 additions & 0 deletions gcp/composer.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"config": {
"allow-plugins": true
},
"require": {
"mediawiki/sub-page-list": "~3.0",
"wikimedia/normalized-exception": "v1.0.1",
"wikimedia/at-ease": "v2.1.0"
},
"extra": {
"merge-plugin": {
"include": [
"extensions/TimedMediaHandler/composer.json",
"extensions/Widgets/composer.json",
"extensions/SendGrid/composer.json"
]
}
}
}
24 changes: 24 additions & 0 deletions gcp/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
mediawiki:
build: .
ports:
- 8080:80
volumes:
- ./images:/var/www/html/images
- ./LocalSettings.php:/var/www/html/LocalSettings.php
- ../mediawiki-bugzilla/:/var/www/html/extensions/Bugzilla # can be removed once our changes are upstream
db:
image: docker.io/mariadb:11
restart: always
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '127.0.0.1:3306:3306'
volumes:
- data:/var/lib/mysql
- ./wiki.sql:/docker-entrypoint-initdb.d/wiki.sql
volumes:
data:
1 change: 1 addition & 0 deletions gcp/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING
23 changes: 23 additions & 0 deletions gcp/podman-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
mediawiki:
image: docker.io/mediawiki:1.39
ports:
- 8080:80
volumes:
- /var/www/html/images
- ./LocalSettings.php:/var/www/html/LocalSettings.php
db:
image: docker.io/mariadb:11
restart: always
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '127.0.0.1:3306:3306'
volumes:
- data:/var/lib/mysql
- ./wiki.sql:/docker-entrypoint-initdb.d/wiki.sql
volumes:
data:
13 changes: 13 additions & 0 deletions gcp/ports.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8000

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>
1 change: 1 addition & 0 deletions gcp/test/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.1
7 changes: 7 additions & 0 deletions gcp/test/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'nokogiri', '~> 1.16'

gem 'typhoeus', '~> 1.4'
41 changes: 41 additions & 0 deletions gcp/test/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
GEM
remote: https://rubygems.org/
specs:
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
racc (1.8.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)

PLATFORMS
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
nokogiri (~> 1.16)
typhoeus (~> 1.4)

BUNDLED WITH
2.5.9
50 changes: 50 additions & 0 deletions gcp/test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require 'typhoeus'
require 'nokogiri'

BASE_URL_PROD = 'https://wiki.mozilla.org'
BASE_URL_TEST = 'http://localhost:8080/index.php'

INSPECT_ELEMENT = '#content'

TEST_PAGES_COUNT = 1000
TEST_KEYWORDS = ['Warning: ', 'Error: '].freeze

def fetch_page(url)
response = Typhoeus.get(url, followlocation: true)
url = response.effective_url
html = response.response_body
code = response.response_code

puts "WARN: #{url} Status code is #{code}" unless code == 200

[html, url]
end

def parse_html(html)
parsed_data = Nokogiri::HTML.parse(html)

parsed_data.css(INSPECT_ELEMENT).inner_text
end

def pages_equal?(prod_page, test_page, keyword)
prod_has_keyword = prod_page.include?(keyword)
test_has_keyword = test_page.include?(keyword)

puts "NOK: #{url} (#{prod_has_keyword})" if prod_has_keyword != test_has_keyword
end

TEST_PAGES_COUNT.times do |i|
html, url = fetch_page("#{BASE_URL_PROD}/Special:Random")
prod_page = parse_html(html)

html, = fetch_page(url.gsub(BASE_URL_PROD, BASE_URL_TEST))
test_page = parse_html(html)

print "\r#{i}"

TEST_KEYWORDS.each do |keyword|
pages_equal?(prod_page, test_page, keyword)
end
end