CanastaWiki / Canasta

MediaWiki Docker image for Canasta, an all-in-one MediaWiki stack for easy deployment and management of enterprise-ready MediaWiki on production environments.
https://www.canasta.wiki
MIT License
38 stars 28 forks source link

Preliminary Implementation of Wiki Farm Support for Canasta #250

Closed chl178 closed 1 year ago

chl178 commented 1 year ago

Related Issue #57

This pull request outlines my progress on the project as part of the Google Summer of Code (GSoC) program. The objective of the project is to implement support for a wiki farm in Canasta, a Docker-based MediaWiki distribution.

Background

Currently, Canasta offers a streamlined way to set up a feature-rich MediaWiki instance on virtually any server. However, it does not currently support running multiple wikis, or a wiki farm, within the same container. This project aims to fill this gap and provide the ability to run different wikis in the same container. The wikis could vary by directory (e.g., example.com/a, example.com/b), subdomain (e.g., a.example.com, b.example.com), or completely different domains (e.g., example1.com, example2.com).

In addition, this project intends to extend Canasta's command-line interface (CLI) to support wiki farm configuration. This would allow administrators to effortlessly create, manage, and delete individual wikis.

Implementation Approach

To simplify management and facilitate use, I've implemented a shared common setting that applies to all wikis. Alongside this commonality, each wiki is distinguished by its unique ID and has its own customized settings. This allows for the definition of unique skins, extensions and configurations for each wiki. In this way, multiple wikis can run independently in a single container.

For wikis under directories, I have scripted an automatic generator generatewikihtaccess.sh for .htaccess files to manage access permissions.

Test

As you can see three different wiki a, k and local run independently in one container. Screenshot from 2023-06-04 19-33-23 Screenshot from 2023-06-04 19-34-56 Screenshot from 2023-06-04 19-35-12 They are under different domain names and different directories.

Next Steps

While this initial implementation is a significant step towards our goal, there is still considerable work to do. The next phase of this project will focus on developing the Canasta CLI to make it even more user-friendly and efficient in managing wiki farms. I'm looking forward to feedback and suggestions on how we can improve this implementation and successfully deliver the project's objectives.

chl178 commented 1 year ago

For people who want to test it locally

As this is an early version for wiki farm support for Canasta, it currently does not support CLI installation and can only be manually installed using docker-compose. You may refer to the official docker-compose manual installation documentation for guidance. The test template for docker-compose.

  1. Modify your hosts file to add an alias for 127.0.0.1 and restart the Apache service. Screenshot from 2023-06-04 19-54-27
  2. Download my canasta code and create an image by docker build -t canastafarm .
  3. Replace the web image in the docker-compose.override.yml file with the image you've just built. Screenshot from 2023-06-04 19-59-09
  4. Modify the caddyfile file in the docker-compose's config, add an alias in the form of http://{corresponding alias}. Screenshot from 2023-06-04 19-59-42 Note: Because this is local testing, if you use https, you might not be able to access it due to the web server lacking an SSL certificate. Therefore, you need to change https to http in order to disable Caddy's https.
  5. Copy .env.example to .env, and modify MW_SITE_SERVER and MW_SITE_FQDN in the .env file, changing them both to start with http. Screenshot from 2023-06-04 20-02-23
  6. Create a wikis.yaml file and place it in the config directory. Screenshot from 2023-06-04 20-03-20
  7. Run the command docker-compose up -d
  8. Navigate to the installation address and install MediaWiki.
  9. After installation, restart the installation and choose a different database for another wiki (repeat as many times as the number of wikis you wanted to install). Screenshot from 2023-06-04 20-09-57 Screenshot from 2023-06-04 20-12-37
  10. Run the command docker-compose down
  11. Place the LocalSettings.php into the config, and add the commonsettings.php and each wiki's customized LocalSettings_wikiID.php. Screenshot from 2023-06-04 20-04-46 Screenshot from 2023-06-04 20-13-27
  12. Run the command docker-compose up -d to complete the installation.

My docker-compose structure: Screenshot from 2023-06-04 20-21-38

chl178 commented 1 year ago

@yaronkoren @jeffw16

vedmaka commented 1 year ago

Some general comments:

Please do not treat my comments as a call to action but as suggestions

chl178 commented 1 year ago

Some general comments:

  • It looks like some changes to the job runner scripts are also necessary, to make it run against all the farm wikis ( mwjobrunner.sh , mwsitemapgen.sh , mwtranscoder.sh )
  • The update.php run also need to be changed by adding support for multiple wikis
  • Images directories ($wgUploadDirectory) need to be also altered per wiki. Otherwise, files will be overwritten
  • Not quite sure about Canasta preference here, but maybe it'd be nice to have the farm mode switch controlled not by wikis.yaml or CommonSettings.php file presence but by some ENV variable instead

Please do not treat my comments as a call to action but as suggestions

Thank @vedmaka for your comments and feedback: We've already initiated the process of resolving the issues concerning the upload and cache directories. This should ensure that files are not overwritten and each wiki in the farm has its own distinct space.

Regarding the ENV variables, we've had discussions with Daniel, a respected MediaWiki community developer. His advice was not to define too many environment variables. As the current practice in the MediaWiki community is to use a YAML file for setting up farms, we've decided to follow this established practice.

We're taking into account your points on modifying the job runner scripts (mwjobrunner.sh, mwsitemapgen.sh, mwtranscoder.sh), and incorporating support for multiple wikis in update.php.

Thanks again for your suggestions. They're not direct calls to action, but we highly value your input.