有没有办法在使用 docker compose 运行时自动设置 MediaWiki?

问题描述 投票:0回答:1

我将 MediaWiki 与 MariaDB 结合使用,在 Docker 版本 24.0.2 和 Docker Compose 版本 2.18.1 上运行。默认设置效果很好。现在,我想与 GitHub 上的同事合作,理想情况下,他们应该能够克隆存储库并运行

docker compose up
来设置所有内容。根目录中应该已经有一个
LocalSettings.php
文件,该文件将作为 MediaWiki 容器内的卷进行链接。

问题是,通常情况下,运行

docker compose up
后,需要通过浏览器或使用
install.php
脚本手动设置 MediaWiki。如果检测到
LocalSettings.php
文件,则跳过设置,看来数据库未正确设置。

当尝试通过浏览器访问 Wiki 时,我们遇到以下错误消息:

Deprecated: Caller from LCStoreDB::get ignored an error originally raised from LCStoreDB::get: [1146] Table 'my_wiki.l10n_cache' doesn't exist in /var/www/html/includes/debug/MWDebug.php on line 381
[3c48d5308eca6dc9224e9901] 2023-05-31 06:58:04: Fatal exception of type Wikimedia\Rdbms\DBQueryError

有没有办法解决这个问题并让 MediaWiki 在克隆存储库后直接运行?

这是我当前的

docker-compose.yml
文件。我尝试在启动 MediaWiki 容器时运行
update.php
脚本来设置数据库,但我遇到了错误消息
Can not upgrade from versions older than 1.31, please upgrade to that version or later first.
,即使它应该使用图像版本 1.39.3。

# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
  mediawiki:
    image: mediawiki:1.39.3
    restart: always
    ports:
      - 8080:80
    links:
      - database
    volumes:
      - images:/var/www/html/images
      # After initial setup, download LocalSettings.php to the same directory as
      # this yaml and uncomment the following line and use compose to restart
      # the mediawiki service
      - ./LocalSettings.php:/var/www/html/LocalSettings.php
    command: sh -c "php maintenance/update.php"
  # This key also defines the name of the database host used during setup instead of the default "localhost"
  database:
    image: mariadb
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: my_wiki
      MYSQL_USER: wikiuser
      MYSQL_PASSWORD: example
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
    volumes:
      - db:/var/lib/mysql

volumes:
  images:
  db:

这是我手动设置后下载的

LocalSettings.php
文件:

<?php
# This file was automatically generated by the MediaWiki 1.39.3
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See docs/Configuration.md for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
    exit;
}


## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "HI-LONa";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://localhost:8080";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL paths to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogos = [
    '1x' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
    'icon' => "$wgResourceBasePath/resources/assets/change-your-logo-icon.svg",
];

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "";
$wgPasswordSender = "";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "database";
$wgDBname = "my_wiki";
$wgDBuser = "wikiuser";
$wgDBpassword = "example";

# MySQL specific settings
$wgDBprefix = "";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Shared database table
# This has no effect unless $wgSharedDB is also set.
$wgSharedTables[] = "actor";

## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = false;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;

# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;

# Site language code, should be one of the list in ./includes/languages/data/Names.php
$wgLanguageCode = "en-gb";

# Time zone
$wgLocaltimezone = "UTC";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publicly accessible from the web.
#$wgCacheDirectory = "$IP/cache";

$wgSecretKey = "7b136b2940a0158c40955529c9f5e6a7b28c777ef359397a82da99729f48e8c3";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "3bb56c36c2f9ad8b";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

## Default skin: you can change the default skin. Use the internal symbolic
## names, e.g. 'vector' or 'monobook':
$wgDefaultSkin = "vector";

# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MinervaNeue' );
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );


# End of automatically generated settings.
# Add more configuration options below.

任何帮助表示赞赏! :-)

php docker docker-compose mediawiki
1个回答
0
投票

问题出在你的数据库上。您已经在 docker-compose 文件中正确设置了它,我想在您的 LocalSettings 中也是如此。但它仅适用于您在初始化 wiki 时使用的“本地实例”(使用安装脚本或通过网络浏览器页面)。

问题是,即使您在 GitHub 上共享堆栈,数据库的实际数据也会保存在您的卷中(在本例中为 db)。但是,您的同事不会拥有您的数据,只有堆栈。

您可以在服务器上启动您的 wiki,双方都可以通过 SSH 连接。只需在服务器上克隆 GitHub 存储库并启动 docker-compose 堆栈即可。

现在,你们都可以在本地计算机上处理 wiki,然后推送到 GitHub 存储库。然后,使用自动 CI/CD 或手动将更改拉到服务器上。像这样,有关您的 wiki 的所有数据都将保存在数据库卷内,存储在服务器上。

© www.soinside.com 2019 - 2024. All rights reserved.