Adds mediawiki app.

This commit is contained in:
2026-06-19 21:33:14 +00:00
parent 2ebbc65dd3
commit a2e3031b84
10 changed files with 302 additions and 0 deletions

5
mediawiki/app.yaml Normal file
View File

@@ -0,0 +1,5 @@
name: mediawiki
is: mediawiki
description: MediaWiki is the free and open source wiki software that powers Wikipedia and thousands of other wikis.
icon: https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/mediawiki.svg
latest: "1"

View File

@@ -0,0 +1,49 @@
# MediaWiki
MediaWiki is the wiki software that powers Wikipedia. It provides a full-featured collaborative wiki with a rich extension ecosystem.
## Dependencies
- **MySQL** - Database for storing wiki content
- **SMTP** - For email notifications and password resets
## Configuration
Key settings in `config.yaml`:
- **domain** - Where MediaWiki will be accessible
- **storage** - Persistent volume size (default: `2Gi`)
- **siteName** - Name of your wiki (default: `My Wiki`)
- **adminUser** - Admin account username (default: `admin`)
## First-Time Setup
MediaWiki requires a **web-based installer** after deployment to generate `LocalSettings.php`.
1. Add and deploy the app:
```bash
wild app add mediawiki
wild app deploy mediawiki
```
2. Visit `/mw-config/` to run the web installer.
3. In the installer:
- Database type: **MySQL**
- Database host: value of `db.host` from your config
- Database name: value of `db.name` (default: `mediawiki`)
- Database user/password: from your config and `secrets.yaml`
- Admin username/password: set to the values in your config and `secrets.yaml`
4. At the end of the installer, download `LocalSettings.php` and copy it into the pod:
```bash
kubectl cp LocalSettings.php mediawiki/<pod-name>:/var/www/html/LocalSettings.php
```
5. The wiki is now live.
## Notes
- The `secretKey` and `upgradeKey` are auto-generated in `secrets.yaml`
- Extensions can be installed by copying them into the pod's `/var/www/html/extensions/` directory
- The wiki will show a "maintenance mode" page until `LocalSettings.php` is in place

View File

@@ -0,0 +1,64 @@
apiVersion: batch/v1
kind: Job
metadata:
name: mediawiki-db-init
labels:
component: db-init
spec:
template:
metadata:
labels:
component: db-init
spec:
restartPolicy: OnFailure
securityContext:
runAsNonRoot: true
runAsUser: 999
runAsGroup: 999
seccompProfile:
type: RuntimeDefault
containers:
- name: mysql-init
image: mysql:9.1.0
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mediawiki-secrets
key: mysql.rootPassword
- name: DB_HOSTNAME
value: {{ .db.host }}
- name: DB_PORT
value: "{{ .db.port }}"
- name: DB_DATABASE_NAME
value: {{ .db.name }}
- name: DB_USERNAME
value: {{ .db.user }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mediawiki-secrets
key: dbPassword
command:
- /bin/bash
- -c
- |
set -e
until mysql -h ${DB_HOSTNAME} -P ${DB_PORT} -u root -p${MYSQL_ROOT_PASSWORD} -e "SELECT 1" 2>/dev/null; do
echo "Waiting for MySQL..."
sleep 2
done
mysql -h ${DB_HOSTNAME} -P ${DB_PORT} -u root -p${MYSQL_ROOT_PASSWORD} <<EOF
CREATE DATABASE IF NOT EXISTS ${DB_DATABASE_NAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS '${DB_USERNAME}'@'%' IDENTIFIED BY '${DB_PASSWORD}';
ALTER USER '${DB_USERNAME}'@'%' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL PRIVILEGES ON ${DB_DATABASE_NAME}.* TO '${DB_USERNAME}'@'%';
FLUSH PRIVILEGES;
EOF
echo "Done"

View File

@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mediawiki
namespace: mediawiki
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
component: web
template:
metadata:
labels:
component: web
spec:
securityContext:
runAsNonRoot: true
runAsUser: 33
runAsGroup: 33
fsGroup: 33
seccompProfile:
type: RuntimeDefault
containers:
- name: mediawiki
image: mediawiki:1.43.1
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: MEDIAWIKI_DB_TYPE
value: mysql
- name: MEDIAWIKI_DB_HOST
value: "{{ .db.host }}:{{ .db.port }}"
- name: MEDIAWIKI_DB_NAME
value: {{ .db.name }}
- name: MEDIAWIKI_DB_USER
value: {{ .db.user }}
- name: MEDIAWIKI_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mediawiki-secrets
key: dbPassword
resources:
limits:
cpu: 500m
ephemeral-storage: 1Gi
memory: 512Mi
requests:
cpu: 50m
ephemeral-storage: 50Mi
memory: 128Mi
volumeMounts:
- name: mediawiki-data
mountPath: /var/www/html/images
livenessProbe:
httpGet:
path: /wiki/Main_Page
port: 80
initialDelaySeconds: 90
timeoutSeconds: 10
periodSeconds: 30
failureThreshold: 6
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 5
periodSeconds: 10
failureThreshold: 3
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
volumes:
- name: mediawiki-data
persistentVolumeClaim:
claimName: mediawiki-data
restartPolicy: Always

View File

@@ -0,0 +1,26 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mediawiki
namespace: mediawiki
annotations:
external-dns.alpha.kubernetes.io/target: {{ .externalDnsDomain }}
external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
external-dns.alpha.kubernetes.io/ttl: "60"
spec:
ingressClassName: traefik
rules:
- host: {{ .domain }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: mediawiki
port:
number: 80
tls:
- hosts:
- {{ .domain }}
secretName: {{ .tlsSecretName }}

View File

@@ -0,0 +1,16 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: mediawiki
labels:
- includeSelectors: true
pairs:
app: mediawiki
managedBy: kustomize
partOf: wild-cloud
resources:
- namespace.yaml
- db-init-job.yaml
- deployment.yaml
- service.yaml
- ingress.yaml
- pvc.yaml

View File

@@ -0,0 +1,30 @@
version: 1.43.1-1
requires:
- name: mysql
- name: smtp
defaultConfig:
namespace: mediawiki
externalDnsDomain: '{{ .cloud.domain }}'
domain: wiki.{{ .cloud.domain }}
tlsSecretName: wildcard-wild-cloud-tls
storage: 2Gi
siteName: My Wiki
adminUser: admin
db:
host: '{{ .apps.mysql.host }}'
port: "3306"
name: mediawiki
user: mediawiki
smtp:
host: '{{ .apps.smtp.host }}'
port: '{{ .apps.smtp.port }}'
from: '{{ .apps.smtp.from }}'
user: '{{ .apps.smtp.user }}'
defaultSecrets:
- key: adminPassword
- key: secretKey
- key: upgradeKey
- key: dbPassword
- key: smtpPassword
requiredSecrets:
- mysql.rootPassword

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .namespace }}

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mediawiki-data
namespace: mediawiki
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .storage }}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: mediawiki
namespace: mediawiki
spec:
selector:
component: web
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP