From 83e51c361ca3382c5320b9cf0206445df11daf6b Mon Sep 17 00:00:00 2001 From: wizzdom Date: Fri, 13 Sep 2024 15:51:02 +0100 Subject: [PATCH] wiki: refactor and cleanup (#57) - tidy up traefik middlewares - mount db to `/storage`, remove constraint on single host - separate `LocalSettings.php` into its own file for sanity - move wiki-related files to `wiki/` - use traditional wiki skin by default --- jobs/services/mediawiki.hcl | 438 ------------------ jobs/services/wiki/LocalSettings.php | 170 +++++++ jobs/services/{ => wiki}/mediawiki-backup.hcl | 0 jobs/services/wiki/mediawiki.hcl | 257 ++++++++++ 4 files changed, 427 insertions(+), 438 deletions(-) delete mode 100644 jobs/services/mediawiki.hcl create mode 100644 jobs/services/wiki/LocalSettings.php rename jobs/services/{ => wiki}/mediawiki-backup.hcl (100%) create mode 100644 jobs/services/wiki/mediawiki.hcl diff --git a/jobs/services/mediawiki.hcl b/jobs/services/mediawiki.hcl deleted file mode 100644 index 458998f..0000000 --- a/jobs/services/mediawiki.hcl +++ /dev/null @@ -1,438 +0,0 @@ -job "mediawiki" { - datacenters = ["aperture"] - type = "service" - - meta { - domain = "wiki.redbrick.dcu.ie" - } - - group "rbwiki" { - count = 1 - - network { - mode = "bridge" - port "http" { - to = 80 - } - port "fpm" { - to = 9000 - } - port "db" { - to = 3306 - } - } - - service { - name = "rbwiki-web" - port = "http" - - check { - type = "http" - path = "/Main_Page" - interval = "10s" - timeout = "5s" - } - - tags = [ - "traefik.enable=true", - "traefik.port=${NOMAD_PORT_http}", - "traefik.http.routers.rbwiki.rule=Host(`${NOMAD_META_domain}`)", - "traefik.http.routers.rbwiki.entrypoints=web,websecure", - "traefik.http.routers.rbwiki.tls.certresolver=lets-encrypt", - "traefik.http.routers.rbwiki.middlewares=redirect-short-url", - "traefik.http.middlewares.redirect-short-url.redirectregex.regex=https://wiki\\.redbrick\\.dcu\\.ie/index\\.php\\?title=(.*)", - "traefik.http.middlewares.redirect-short-url.redirectregex.replacement=https://wiki.redbrick.dcu.ie/$1", - "traefik.http.routers.rbwiki.middlewares=redirect-root", - "traefik.http.middlewares.redirect-root.redirectregex.regex=^https://wiki\\.redbrick\\.dcu\\.ie/?$", - "traefik.http.middlewares.redirect-root.redirectregex.replacement=https://wiki.redbrick.dcu.ie/Main_Page", - # "traefik.http.routers.rbwiki.middlewares=redirect-mw", - # "traefik.http.middlewares.redirect-mw.redirectregex.regex=https://wiki\\.redbrick\\.dcu\\.ie/Mw/(.*)", - # "traefik.http.middlewares.redirect-mw.redirectregex.replacement=https://wiki.redbrick.dcu.ie/$1", - ] - } - - task "rbwiki-nginx" { - driver = "docker" - config { - image = "nginx:alpine" - ports = ["http"] - volumes = [ - "local/nginx.conf:/etc/nginx/nginx.conf", - "/storage/nomad/mediawiki/extensions:/var/www/html/extensions", - "/storage/nomad/mediawiki/images:/var/www/html/images", - "/storage/nomad/mediawiki/skins:/var/www/html/skins", - "/storage/nomad/mediawiki/resources/assets:/var/www/html/Resources/assets", - ] - } - resources { - cpu = 200 - memory = 100 - } - template { - data = < 'LDAPAuthentication2', - 'data' => [ - 'domain' => 'LDAP' - ], -]; - -# RBOnly Namespace -# To allow semi-public pages -$wgExtraNamespaces = array(100 => "RBOnly", 101 => "RBOnly_talk"); -$wgNamespacesWithSubpages = array( -1 => 0, 0 => 0, 1 => 1, 2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1, 8 => 0, 9 => 1, 10 => 0, 11 => 1,100 => 1,101 => 1); -$wgNamespacesToBeSearchedDefault = array( -1 => 0, 0 => 1, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0,100 => 0,101 => 0); -$wgNonincludableNamespaces[] = 100; - -$wgGroupPermissions['*']['readrbonly'] = false; -$wgGroupPermissions['sysop']['readrbonly'] = true; - -$wgNamespaceProtection[ 100 ] = array( 'readrbonly' ); - -# group permissions -$wgGroupPermissions['*']['autocreateaccount'] = true; -$wgGroupPermissions['*']['createaccount'] = false; -$wgGroupPermissions['*']['read'] = true; -$wgGroupPermissions['*']['edit'] = false; - -# Exclude user group page views from counting. -$wgGroupPermissions['sysop']['hitcounter-exempt'] = true; - -# When set to true, it adds the PageId to the special page "PopularPages". The default value is false. -$wgEnableAddPageId = false; - -# When set to true, it adds the TextLength to the special page "PopularPages". The default value is false. -$wgEnableAddTextLength = true; - -# debug logs -# $wgDebugDumpSql = true; -$wgShowExceptionDetails = true; -$wgShowDBErrorBacktrace = true; -$wgShowSQLErrors = true; -$wgDebugLogFile = "/dev/stderr"; -EOH - - destination = "local/LocalSettings.php" - } - } - - service { - name = "rbwiki-db" - port = "db" - - check { - name = "mariadb_probe" - type = "tcp" - interval = "10s" - timeout = "2s" - } - } - - task "rbwiki-db" { - driver = "docker" - - constraint { - attribute = "${attr.unique.hostname}" - value = "glados" - } - - config { - image = "mariadb" - ports = ["db"] - - volumes = [ - "/opt/mediawiki-db:/var/lib/mysql", - "/oldstorage/wiki_backups:/wiki-backups/backup", - "local/conf.cnf:/etc/mysql/mariadb.conf.d/50-server.cnf", - ] - } - - template { - data = < 'LDAPAuthentication2', + 'data' => [ + 'domain' => 'LDAP' + ], +]; + +# RBOnly Namespace +# To allow semi-public pages +$wgExtraNamespaces = array(100 => "RBOnly", 101 => "RBOnly_talk"); +$wgNamespacesWithSubpages = array( -1 => 0, 0 => 0, 1 => 1, 2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1, 8 => 0, 9 => 1, 10 => 0, 11 => 1,100 => 1,101 => 1); +$wgNamespacesToBeSearchedDefault = array( -1 => 0, 0 => 1, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0,100 => 0,101 => 0); +$wgNonincludableNamespaces[] = 100; + +$wgGroupPermissions['*']['readrbonly'] = false; +$wgGroupPermissions['sysop']['readrbonly'] = true; + +$wgNamespaceProtection[ 100 ] = array( 'readrbonly' ); + +# group permissions +$wgGroupPermissions['*']['autocreateaccount'] = true; +$wgGroupPermissions['*']['createaccount'] = false; +$wgGroupPermissions['*']['read'] = true; +$wgGroupPermissions['*']['edit'] = false; + +# Exclude user group page views from counting. +$wgGroupPermissions['sysop']['hitcounter-exempt'] = true; + +# When set to true, it adds the PageId to the special page "PopularPages". The default value is false. +$wgEnableAddPageId = false; + +# When set to true, it adds the TextLength to the special page "PopularPages". The default value is false. +$wgEnableAddTextLength = true; + +# debug logs +# $wgDebugDumpSql = true; +$wgShowExceptionDetails = true; +$wgShowDBErrorBacktrace = true; +$wgShowSQLErrors = true; +$wgDebugLogFile = "/dev/stderr"; diff --git a/jobs/services/mediawiki-backup.hcl b/jobs/services/wiki/mediawiki-backup.hcl similarity index 100% rename from jobs/services/mediawiki-backup.hcl rename to jobs/services/wiki/mediawiki-backup.hcl diff --git a/jobs/services/wiki/mediawiki.hcl b/jobs/services/wiki/mediawiki.hcl new file mode 100644 index 0000000..677688b --- /dev/null +++ b/jobs/services/wiki/mediawiki.hcl @@ -0,0 +1,257 @@ +job "mediawiki" { + datacenters = ["aperture"] + type = "service" + + meta { + domain = "wiki.redbrick.dcu.ie" + } + + group "rbwiki" { + count = 1 + + network { + mode = "bridge" + port "http" { + to = 80 + } + port "fpm" { + to = 9000 + } + port "db" { + to = 3306 + } + } + + service { + name = "rbwiki-web" + port = "http" + + check { + type = "http" + path = "/Main_Page" + interval = "10s" + timeout = "5s" + } + + tags = [ + "traefik.enable=true", + "traefik.port=${NOMAD_PORT_http}", + "traefik.http.routers.rbwiki.rule=Host(`${NOMAD_META_domain}`) || Host(`wiki.rb.dcu.ie`)", + "traefik.http.routers.rbwiki.entrypoints=web,websecure", + "traefik.http.routers.rbwiki.tls.certresolver=lets-encrypt", + "traefik.http.routers.rbwiki.middlewares=rbwiki-redirect-root, rbwiki-redirect-mw", + "traefik.http.middlewares.rbwiki-redirect-root.redirectregex.regex=^https://wiki\\.redbrick\\.dcu\\.ie/?$", + "traefik.http.middlewares.rbwiki-redirect-root.redirectregex.replacement=https://wiki.redbrick.dcu.ie/Main_Page", + "traefik.http.middlewares.rbwiki-redirect-mw.redirectregex.regex=https://wiki\\.redbrick\\.dcu\\.ie/Mw/(.*)", + "traefik.http.middlewares.rbwiki-redirect-mw.redirectregex.replacement=https://wiki.redbrick.dcu.ie/$1", + ] + } + + task "rbwiki-nginx" { + driver = "docker" + config { + image = "nginx:alpine" + ports = ["http"] + volumes = [ + "local/nginx.conf:/etc/nginx/nginx.conf", + "/storage/nomad/mediawiki/extensions:/var/www/html/extensions", + "/storage/nomad/mediawiki/images:/var/www/html/images", + "/storage/nomad/mediawiki/skins:/var/www/html/skins", + "/storage/nomad/mediawiki/resources/assets:/var/www/html/Resources/assets", + ] + } + resources { + cpu = 200 + memory = 100 + } + template { + data = <