Skip to content

Commit 6c6e524

Browse files
committed
mediawiki\nosticket\fix mariadb to work with names with dashes
1 parent 138f306 commit 6c6e524

10 files changed

Lines changed: 232 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ experiments/influxdb/config/influx-configs
105105
# [experiments] experiments/llama-router/.gitignore
106106
experiments/llama-router/.env
107107

108+
# [experiments] experiments/mediawiki/.gitignore
109+
experiments/mediawiki/.env
110+
108111
# [experiments] experiments/nextcloud/.gitignore
109112
experiments/nextcloud/.env
110113

apps/mariadb/bin/mkdb.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/bin/bash
22

3+
# MySQL/MariaDB single-quoted string (user name, password).
4+
mysql_escape_sq() {
5+
printf '%s' "${1//\'/\'\'}"
6+
}
7+
8+
# Backtick-quoted identifier (database name).
9+
mysql_ident_bt() {
10+
printf '`%s`' "${1//\`/\`\`}"
11+
}
12+
313
if [ "$#" -ne 1 ]; then
414
echo "Usage: $0 <application name>"
515
exit 1
@@ -48,14 +58,15 @@ fi
4858
echo "✓ MariaDB container is running"
4959
echo
5060

61+
eu=$(mysql_escape_sq "$USER")
62+
ep=$(mysql_escape_sq "$PASSWORD")
63+
dbq=$(mysql_ident_bt "$DATABASE")
64+
65+
sql="CREATE USER IF NOT EXISTS '${eu}'@'%' IDENTIFIED BY '${ep}'; CREATE DATABASE IF NOT EXISTS ${dbq}; GRANT ALL PRIVILEGES ON ${dbq}.* TO '${eu}'@'%'; FLUSH PRIVILEGES;"
66+
5167
echo "1. creating user, database, and grants"
5268
echo " docker compose -f $COMPOSE_FILE exec -T mariadb mariadb -u root -p*** ..."
53-
if docker compose -f "$COMPOSE_FILE" exec -T mariadb mariadb -u root -p"${MARIADB_ROOT_PASSWORD}" << EOF
54-
CREATE USER IF NOT EXISTS '${USER}'@'%' IDENTIFIED BY '${PASSWORD}';
55-
CREATE DATABASE IF NOT EXISTS \`${DATABASE}\`;
56-
GRANT ALL PRIVILEGES ON \`${DATABASE}\`.* TO '${USER}'@'%';
57-
FLUSH PRIVILEGES;
58-
EOF
69+
if docker compose -f "$COMPOSE_FILE" exec -T mariadb mariadb -u root -p"${MARIADB_ROOT_PASSWORD}" -e "$sql"
5970
then
6071
echo " ✓ User, database, and grants applied"
6172
else

experiments/mediawiki/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Official tags: lts, stable, latest (see https://hub.docker.com/_/mediawiki )
2+
IMAGE_VERSION=lts
3+
4+
# Optional
5+
# TZ=America/Los_Angeles

experiments/mediawiki/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

experiments/mediawiki/.rsync-exclude

Whitespace-only changes.

experiments/mediawiki/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# mediawiki (experiment)
2+
3+
[MediaWiki](https://www.mediawiki.org/) using the official **[`mediawiki`](https://hub.docker.com/_/mediawiki)** Apache image and the **shared MariaDB** service (`mariadb` on `mariadb-net`).
4+
5+
The image includes **MySQL/MariaDB** support (`mysqli`) only, not PostgreSQL—use **`apps/mariadb`**, not `apps/postgresql`, for the database.
6+
7+
## Prerequisites
8+
9+
1. **`nginx-proxy-net`** (e.g. from `nginx-proxy-manager`) and **`mariadb-net`** (from `apps/mariadb`) must exist; MariaDB must be running.
10+
11+
2. Create an application database and user (names and password are up to you; `mediawiki` is a common prefix):
12+
13+
```bash
14+
../../apps/mariadb/bin/mkdb.sh mediawiki
15+
```
16+
17+
That creates **`mediawiki_db`**, **`mediawiki_user`**, and a generated password (and may append **`BACKUP_DATABASE_URLS`** to this directory’s `.env` if present).
18+
19+
3. Create the images volume directory on the host:
20+
21+
```bash
22+
mkdir -p ../../lib/mediawiki/images
23+
```
24+
25+
## Configuration
26+
27+
```bash
28+
cp .env.example .env
29+
```
30+
31+
Set **`IMAGE_VERSION`** if you pin a tag. Optionally set **`TZ`**.
32+
33+
## First-time web install
34+
35+
1. Point your reverse proxy at **`mediawiki:80`** (or publish **`80`** temporarily—see commented **`ports`** in **`docker-compose.yml`**).
36+
37+
2. Open the wiki URL in a browser. On **“Set up database”** use:
38+
39+
- Database type: **MySQL/MariaDB**
40+
- Database host: **`mariadb`**
41+
- Database name: **`mediawiki_db`** (or whatever you used with **`mkdb.sh`**)
42+
- Database user / password: **`mediawiki_user`** / password from **`mkdb.sh`**
43+
44+
3. When the installer offers **`LocalSettings.php`**, save it as **`../../lib/mediawiki/LocalSettings.php`** on the host.
45+
46+
4. Uncomment the **`LocalSettings.php`** bind mount in **`docker-compose.yml`** and **`docker compose up -d`** again so upgrades and restarts keep your settings.
47+
48+
## Networks
49+
50+
- **`nginx-proxy-net`** — browser access via proxy
51+
- **`mariadb-net`** — SQL to **`mariadb:3306`**
52+
53+
## Usage
54+
55+
```bash
56+
docker compose up -d
57+
docker compose down
58+
docker compose logs -f
59+
```
60+
61+
## Healthcheck
62+
63+
HTTP **`GET /`** on **`127.0.0.1:80`** inside the container.
64+
65+
## Backup
66+
67+
- MariaDB: include your wiki database in normal DB backups; **`mkdb.sh`** can add **`BACKUP_DATABASE_URLS`** to `.env`.
68+
- Files: back up **`../../lib/mediawiki`** (`images/` and **`LocalSettings.php`** after install).
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
mediawiki:
3+
image: mediawiki:${IMAGE_VERSION:-lts}
4+
container_name: mediawiki
5+
hostname: mediawiki
6+
restart: unless-stopped
7+
volumes:
8+
- ../../lib/mediawiki/images:/var/www/html/images
9+
# After the web installer: save LocalSettings.php to ../../lib/mediawiki/ then uncomment:
10+
# - ../../lib/mediawiki/LocalSettings.php:/var/www/html/LocalSettings.php
11+
env_file:
12+
- .env
13+
healthcheck:
14+
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1/ -o /dev/null || exit 1"]
15+
interval: 30s
16+
timeout: 10s
17+
retries: 3
18+
start_period: 90s
19+
# ports:
20+
# - 8080:80
21+
networks:
22+
- proxy
23+
- mariadb
24+
25+
networks:
26+
proxy:
27+
external: true
28+
name: nginx-proxy-net
29+
mariadb:
30+
external: true
31+
name: mariadb-net

experiments/osticket/.env.example

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
IMAGE_VERSION=latest
2+
3+
# tiredofit/osticket base image
4+
TIMEZONE=America/Los_Angeles
5+
CONTAINER_NAME=osticket
6+
7+
# MariaDB (shared mariadb service on mariadb-net)
8+
DB_HOST=mariadb
9+
DB_PORT=3306
10+
DB_NAME=osticket_db
11+
DB_USER=osticket_user
12+
DB_PASS=<DATABASE_PASSWORD>
13+
DB_PREFIX=ost_
14+
15+
# First-time install (set before first start; keep stable after install)
16+
INSTALL_SECRET=<LONG_RANDOM_STRING>
17+
INSTALL_EMAIL=helpdesk@pdxhackerspace.org
18+
INSTALL_NAME=Helpdesk
19+
20+
ADMIN_FIRSTNAME=Admin
21+
ADMIN_LASTNAME=User
22+
ADMIN_EMAIL=admin@pdxhackerspace.org
23+
ADMIN_USER=ostadmin
24+
ADMIN_PASS=<ADMIN_PASSWORD>
25+
26+
CRON_INTERVAL=10
27+
28+
# Outgoing mail (optional; point at your SMTP or shared postfix)
29+
SMTP_HOST=
30+
SMTP_PORT=587
31+
SMTP_FROM=helpdesk@pdxhackerspace.org
32+
SMTP_TLS=1
33+
SMTP_USER=
34+
SMTP_PASS=
35+
36+
# Automatic database backup URL
37+
BACKUP_DATABASE_URLS=mysql://osticket_user:<DATABASE_PASSWORD>@mariadb:3306/osticket_db

experiments/osticket/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# osticket
2+
3+
Open source help desk and ticketing (experiment).
4+
5+
Uses the shared MariaDB instance; create the database and user there before the first start.
6+
7+
## Configuration
8+
9+
### Environment Variables
10+
11+
Copy `.env.example` to `.env` and configure:
12+
13+
```bash
14+
cp .env.example .env
15+
# Edit .env with your settings
16+
```
17+
18+
## Usage
19+
20+
### Starting the service
21+
22+
```bash
23+
docker compose up -d
24+
```
25+
26+
### Stopping the service
27+
28+
```bash
29+
docker compose down
30+
```
31+
32+
### Viewing logs
33+
34+
```bash
35+
docker compose logs -f
36+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
osticket:
3+
image: tiredofit/osticket:${IMAGE_VERSION:-latest}
4+
container_name: osticket
5+
hostname: osticket
6+
restart: unless-stopped
7+
volumes:
8+
- ../../lib/osticket:/www/osticket
9+
- ../../log/osticket:/www/logs
10+
# ports:
11+
# - 8080:80
12+
env_file:
13+
- .env
14+
networks:
15+
- proxy
16+
- mariadb
17+
healthcheck:
18+
test:
19+
[
20+
"CMD-SHELL",
21+
"wget -nv --tries=1 --spider http://127.0.0.1/ || exit 1",
22+
]
23+
interval: 30s
24+
timeout: 10s
25+
retries: 5
26+
start_period: 300s
27+
28+
networks:
29+
proxy:
30+
external: true
31+
name: nginx-proxy-net
32+
mariadb:
33+
external: true
34+
name: mariadb-net

0 commit comments

Comments
 (0)