commit fd122d4ea998dfbed56d5dd0b9804becc41c82bd Author: Konstantin Pereiaslov Date: Sun Mar 30 14:42:55 2025 -0500 Initial set up diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..aaea082 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +VIRTUAL_HOST=siepatchwiki.test +LETSENCRYPT_HOST=siepatchwiki.test +LETSENCRYPT_EMAIL=test@example.com +GENERATE_HTTPS_LINKS=0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..115e3c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +mediawiki +data diff --git a/LocalSettings.php b/LocalSettings.php new file mode 100644 index 0000000..188d6c8 --- /dev/null +++ b/LocalSettings.php @@ -0,0 +1,189 @@ + "$wgResourceBasePath/img/logo.jpg", + 'icon' => "$wgResourceBasePath/img/logo.jpg", +]; + +## 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 = "sqlite"; +$wgDBserver = ""; +$wgDBname = "siepatch"; +$wgDBuser = ""; +$wgDBpassword = ""; + +# SQLite-specific settings +$wgSQLiteDataDir = "/data"; +$wgObjectCaches[CACHE_DB] = [ + 'class' => SqlBagOStuff::class, + 'loggroup' => 'SQLBagOStuff', + 'server' => [ + 'type' => 'sqlite', + 'dbname' => 'wikicache', + 'tablePrefix' => '', + 'variables' => [ 'synchronous' => 'NORMAL' ], + 'dbDirectory' => $wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', + 'flags' => 0 + ] +]; +$wgLocalisationCacheConf['storeServer'] = [ + 'type' => 'sqlite', + 'dbname' => "{$wgDBname}_l10n_cache", + 'tablePrefix' => '', + 'variables' => [ 'synchronous' => 'NORMAL' ], + 'dbDirectory' => $wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', + 'flags' => 0 +]; +$wgJobTypeConf['default'] = [ + 'class' => 'JobQueueDB', + 'claimTTL' => 3600, + 'server' => [ + 'type' => 'sqlite', + 'dbname' => "{$wgDBname}_jobqueue", + 'tablePrefix' => '', + 'variables' => [ 'synchronous' => 'NORMAL' ], + 'dbDirectory' => $wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', + 'flags' => 0 + ] +]; +$wgResourceLoaderUseObjectCacheForDeps = true; + +# Shared database table +# This has no effect unless $wgSharedDB is also set. +$wgSharedTables[] = "actor"; + +## Shared memory settings +$wgMainCacheType = CACHE_ACCEL; +$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"; + +# 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 = "ea457abddb0fa57ecfb5eec830659f1d3d3b4da9415205b54d462a9243541ba5"; + +# 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 = "33762ec359a83929"; + +## 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 = "minerva"; + +# 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. + +wfLoadExtension( 'VisualEditor' ); +$wgGroupPermissions['user']['writeapi'] = true; +wfLoadExtension( 'WikiEditor' ); +//wfLoadExtension( 'DiscussionTools' ); +// Optional: Set VisualEditor as the default editor for anonymous users +// otherwise they will have to switch to VE +$wgDefaultUserOptions['visualeditor-editor'] = "visualeditor"; + +// Optional: Don't allow users to disable it +$wgHiddenPrefs[] = 'visualeditor-enable'; + +// Optional: Enable VisualEditor's experimental code features +$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1; + +// Activate ONLY the 2017 wikitext editor by default +$wgDefaultUserOptions['visualeditor-autodisable'] = true; +$wgDefaultUserOptions['visualeditor-newwikitext'] = 1; diff --git a/README.md b/README.md new file mode 100644 index 0000000..9cf94bf --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +1. Make sure docker-compose is installed and invoked as `docker-compose` +2. `cp .env.example .env` and edit accordingly +3. `./init.sh` +4. Put the database into /data directory, images into /data/images diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..183ec6d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +services: + nginx: + build: nginx + restart: always + volumes: + - ./mediawiki/:/app + - ./data/images:/app/images + - ./img/:/img + links: + - "php-fpm" + environment: + VIRTUAL_HOST: ${VIRTUAL_HOST} + LETSENCRYPT_HOST: ${LETSENCRYPT_HOST} + LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} + php-fpm: + build: php-fpm + volumes: + - ./mediawiki:/app + - ./data/images:/app/images + - ./data:/data + restart: always +networks: + default: + name: nginx-proxy + external: true diff --git a/img/logo.jpg b/img/logo.jpg new file mode 100644 index 0000000..f24dd3c Binary files /dev/null and b/img/logo.jpg differ diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..466ac88 --- /dev/null +++ b/init.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e +if [ -d mediawiki ]; then + echo "\"mediawiki\" directory alrady exists, skipping mediawiki installation" + else +mkdir mediawiki|| (echo "Failed to create \"mediawiki\" directory" && exit 1) +curl https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.0.tar.gz -o /tmp/mediawiki-1.43.0.tar.gz || (echo "Failed to download mediawiki" && exit 1) +tar -xvf /tmp/mediawiki-1.43.0.tar.gz -C ./mediawiki --strip-components=1 || (echo "Failed to extract mediawiki" && exit 1) +fi +set -a && source .env && set +a +cp LocalSettings.php mediawiki/ +ESCAPED_VIRTUAL_HOST="$(printf '%s' "$VIRTUAL_HOST" | sed 's/[.\*\+\?\(\)\|\^\$\[\]{}\\]/\\&/g')" +if [ "$GENERATE_HTTPS_LINKS" == "1" ]; then + PREFIX='https' +else + PREFIX='http' +fi +sed -i "s,http://siepatchwiki\.test,${PREFIX}://${ESCAPED_VIRTUAL_HOST},g" mediawiki/LocalSettings.php +mkdir -p data/deleted-files +mkdir -p data/images +chmod -R 777 data || true +docker-compose up -d diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..7a101b2 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:1.27.4-alpine +COPY default.conf /etc/nginx/conf.d/default.conf diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..d0a6592 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,64 @@ +server { + listen 80; + server_name _; + root /app; + index index.php; + charset utf-8; + error_log /dev/stdout info; + #Cloudflare support + set_real_ip_from 103.21.244.0/22; + set_real_ip_from 103.22.200.0/22; + set_real_ip_from 103.31.4.0/22; + set_real_ip_from 104.16.0.0/12; + set_real_ip_from 108.162.192.0/18; + set_real_ip_from 141.101.64.0/18; + set_real_ip_from 162.158.0.0/15; + set_real_ip_from 172.64.0.0/13; + set_real_ip_from 173.245.48.0/20; + set_real_ip_from 188.114.96.0/20; + set_real_ip_from 190.93.240.0/20; + set_real_ip_from 197.234.240.0/22; + set_real_ip_from 198.41.128.0/17; + set_real_ip_from 2400:cb00::/32; + set_real_ip_from 2606:4700::/32; + set_real_ip_from 2803:f800::/32; + set_real_ip_from 2405:b500::/32; + set_real_ip_from 2405:8100::/32; + set_real_ip_from 2c0f:f248::/32; + set_real_ip_from 2a06:98c0::/29; + + # use any of the following two + real_ip_header CF-Connecting-IP; + #real_ip_header X-Forwarded-For; + + error_page 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + location / { + try_files $uri $uri/ =404; + } + location /images { + try_files $uri =404; + add_header X-Content-Type-Options nosniff; + } + location /img { + alias /img/; + try_files $uri =404; + add_header X-Content-Type-Options nosniff; + } + + location ~ /vendor/ { deny all; } + location ~ /cache/ { deny all; } + location ~ /tests/ { deny all; } + location ~ /maintenance/ { deny all; } + location ~ /languages/ { deny all; } + location ~ /includes/ { deny all; } + location ~ /mw-config/ { deny all; } + location ~ \.php$ { + fastcgi_pass php-fpm:9000; + fastcgi_intercept_errors on; + fastcgi_param SCRIPT_FILENAME /app/$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile new file mode 100644 index 0000000..356e539 --- /dev/null +++ b/php-fpm/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.3-fpm-alpine3.20 +RUN apk add php83-sqlite3 git diffutils +RUN mkdir /data && chmod 777 /data +RUN set -ex \ + && apk --no-cache add icu-dev libjpeg-turbo-dev libpng-dev freetype-dev zlib-dev \ + && apk --no-cache add --virtual .build-deps $PHPIZE_DEPS \ + && docker-php-ext-configure intl \ + && docker-php-ext-configure gd --with-jpeg --with-freetype \ + && docker-php-ext-install -j"$(nproc)" intl gd \ + && pecl install apcu \ + && docker-php-ext-enable apcu \ + && apk del .build-deps +CMD ["php-fpm"]