Dev › Gnuboard

Running Gnuboard5 locally with Docker Compose and Dev Containers

Set up Gnuboard5 v5.6.58 with PHP 8.5, MariaDB 11.8, and Mailpit using Docker Compose and Dev Containers, including data volume isolation and mail checks.

Running Gnuboard5 locally with Docker Compose and Dev Containers

Local Gnuboard5 (v5.6.58) setups often stall on three things: missing PHP extensions, data/ permission errors on bind mounts, and security emails that refuse to send without G5_DOMAIN and an SMTP server. Here is how the Docker Compose and VS Code Dev Container stack in commit 335783c34 solves all three on PHP 8.5.13, MariaDB 11.8.10, and Mailpit v1.34.1.

Every command and output in this post was verified locally against Gnuboard5 v5.6.58 (public commit 335783c34) running php:8.5-apache-trixie, mariadb:11.8, and axllent/mailpit:v1.34.1.

Three friction points in local Gnuboard5 setups

Installing Apache, PHP, and MariaDB directly on your host machine works until you switch PHP versions or reset a test install. Three issues come up repeatedly:

  1. Extension drift across hosts. The web installer (/install/) requires mysqli, json, iconv, and gd, and recommends mbstring, openssl, and curl. Optional features also rely on exif for image orientation, zip for Excel exports, soap for legacy YoungCart integrations, and SimpleXML. Package names and GD flags (FreeType, JPEG, WebP) differ across OSes.
  2. Writable data/ directories on bind mounts. Mounting the repository root directly into /var/www/html leaves Apache (www-data) unable to write data/dbconfig.php or uploaded files. The usual workaround—chmod 707 data on the host—mixes container-owned files into your working tree.
  3. Local email testing with G5_DOMAIN checks. Password reset and verification emails in Gnuboard5 require both an SMTP target and a valid G5_DOMAIN. Wiring a real SMTP account just to test local flows slows down iteration and risks sending noise to real inboxes.

Container topology, loopback ports, and health checks

The compose.yaml file splits the stack into three services: web, db, and mailpit. Host access stays restricted to 127.0.0.1, while containers talk over the internal Compose network (db:3306 and mailpit:1025).

flowchart TD
    Host["Host Browser / IDE (127.0.0.1)"] -->|"HTTP :8080"| Web["web (PHP 8.5 + Apache)"]
    Host -->|"Web UI :8025"| Mailpit["mailpit (v1.34.1)"]
    Web -->|"SQL db:3306"| DB["db (MariaDB 11.8)"]
    Web -->|"SMTP mailpit:1025"| Mailpit
    Web -->|"Overlay /var/www/html/data"| Vol["gnuboard-data volume"]

Here is the full compose.yaml at the repository root:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# compose.yaml
services:
  web:
    build: .devcontainer
    command:
      - sh
      - -ec
      - |
        install -d -o www-data -g www-data -m 0755 /var/www/html/data
        exec apache2-foreground
    environment:
      G5_DOMAIN: "http://127.0.0.1:${GNUBOARD_WEB_PORT:-8080}"
      G5_SMTP: mailpit
      G5_SMTP_PORT: "1025"
    ports:
      - "127.0.0.1:${GNUBOARD_WEB_PORT:-8080}:80"
    volumes:
      - .:/var/www/html
      - gnuboard-data:/var/www/html/data
    depends_on:
      db:
        condition: service_healthy
      mailpit:
        condition: service_healthy

  db:
    image: mariadb:11.8
    environment:
      MARIADB_DATABASE: gnuboard
      MARIADB_USER: gnuboard
      MARIADB_PASSWORD: gnuboard
      MARIADB_RANDOM_ROOT_PASSWORD: "1"
    ports:
      - "127.0.0.1:${GNUBOARD_DB_PORT:-3306}:3306"
    volumes:
      - db-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 5s
      timeout: 5s
      retries: 12
      start_period: 30s

  mailpit:
    image: axllent/mailpit:v1.34.1
    ports:
      - "127.0.0.1:${GNUBOARD_MAILPIT_PORT:-8025}:8025"

volumes:
  gnuboard-data:
  db-data:

Three design details matter here:

  • Loopback-only ports with .env sync. Every exposed port binds to 127.0.0.1, keeping the local database and Mailpit UI off your LAN. If 8080, 3306, or 8025 is already taken on your machine, override GNUBOARD_WEB_PORT, GNUBOARD_DB_PORT, or GNUBOARD_MAILPIT_PORT in a root .env file (ignored by .gitignore). Because G5_DOMAIN reads the same ${GNUBOARD_WEB_PORT:-8080} variable, generated links stay in sync without editing compose.yaml.
  • MariaDB 11.8 healthcheck.sh and random root passwords. Instead of a bare TCP check, db runs MariaDB’s official healthcheck.sh --connect --innodb_initialized. That waits until InnoDB finishes bootstrapping before marking db healthy, avoiding the startup race I covered in controlling Docker Compose startup order with depends_on and service_healthy. Setting MARIADB_RANDOM_ROOT_PASSWORD: "1" avoids hardcoding a root password while the app connects with the gnuboard user.
  • Inherited Mailpit HEALTHCHECK. You might notice mailpit has no healthcheck: block in compose.yaml, yet depends_on: condition: service_healthy still works. The axllent/mailpit:v1.34.1 image defines its own HEALTHCHECK using /mailpit readyz:
1
docker image inspect axllent/mailpit:v1.34.1 --format '{{json .Config.Healthcheck}}'
1
{"Test":["CMD","/mailpit","readyz"],"Interval":15000000000,"StartPeriod":10000000000,"StartInterval":1000000000}

In my local test run (docker compose up -d --build), mailpit turned healthy in 1.8 s and db (11.8.10-MariaDB-ubu2404) in 5.7 s, and web started right after both passed.

PHP 8.5 extensions and Apache dotfile blocking

The web image starts from php:8.5-apache-trixie (PHP 8.5.13, Apache/2.4.71, Debian 13 trixie) and compiles only the five missing extensions.

1
2
3
4
5
6
7
8
9
10
11
12
13
# .devcontainer/Dockerfile
FROM php:8.5-apache-trixie

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        git libfreetype-dev libjpeg62-turbo-dev libpng-dev libwebp-dev libxml2-dev libzip-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
    && docker-php-ext-install -j"$(nproc)" exif gd mysqli soap zip \
    && rm -rf /var/lib/apt/lists/* \
    && useradd --create-home --shell /bin/bash developer

COPY gnuboard.conf /etc/apache2/conf-available/gnuboard.conf
RUN a2enmod rewrite && a2enconf gnuboard

Out of the 11 extensions listed across install/library.check.php and README.md, six ship with the base image and five come from docker-php-ext-install:

TierExtensionsSource in php:8.5-apache-trixiePurpose
Required (4)json, iconvBuilt-inInstaller responses, character encoding
Required (4)mysqli, gdCompiled (freetype, jpeg, webp)MariaDB driver, CAPTCHA and thumbnails
Recommended (3)mbstring, openssl, curlBuilt-inMultibyte strings, TLS, external API calls
Optional (4)SimpleXMLBuilt-inXML parsing
Optional (4)exif, zip, soapCompiledImage orientation, Excel export, YoungCart hooks

Running php -m and gd_info() inside the container confirms all 11 extensions load with FreeType, JPEG, and WebP enabled. Opening /install/ shows all seven installer environment checks passing (확인 means verified in the Korean installer UI).

Gnuboard5 step-1 installer screen showing all seven required and recommended server environment checks passing Figure 1. Gnuboard5 /install/ environment check running on local php:8.5-apache-trixie (PHP 8.5.13), with all four required and three recommended checks passing.

Mounting the entire repository root into /var/www/html exposes .git/, .env, .devcontainer/, and compose.yaml under Apache’s document root unless you block them explicitly. At the same time, Gnuboard5’s short URLs rely on .htaccess rewrite rules. .devcontainer/gnuboard.conf handles both:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# .devcontainer/gnuboard.conf
ServerName localhost

<Directory /var/www/html>
    Options -Indexes
    AllowOverride All

    <FilesMatch "^\.|^compose\.yaml$">
        Require all denied
    </FilesMatch>
</Directory>

<DirectoryMatch "^/var/www/html/(?:[^/]+/)*\.">
    Require all denied
</DirectoryMatch>

Options -Indexes disables directory listings, AllowOverride All plus a2enmod rewrite enables .htaccess rewrites, and the <FilesMatch> and <DirectoryMatch> blocks deny dotfiles, dot-directories, and compose.yaml. Checking the running container with curl confirms the rules:

1
2
3
4
for p in "/.env" "/.git/HEAD" "/.devcontainer/devcontainer.json" "/compose.yaml" "/img/" "/" "/install/"; do
  code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:8080${p}")
  echo "GET ${p} -> HTTP ${code}"
done
1
2
3
4
5
6
7
GET /.env -> HTTP 403
GET /.git/HEAD -> HTTP 403
GET /.devcontainer/devcontainer.json -> HTTP 403
GET /compose.yaml -> HTTP 403
GET /img/ -> HTTP 403
GET / -> HTTP 200
GET /install/ -> HTTP 200

All five protected paths return 403 Forbidden, while / and /install/ return 200.

Overlaying the data volume and wiring Mailpit

You want live code edits from the host (.:/var/www/html), but you don’t want Apache writing runtime files into your host tree. Overlaying a named volume (gnuboard-data:/var/www/html/data) on top of the bind mount isolates runtime writes, following the pattern from managing Docker volume and bind mount permissions.

Right before starting Apache, the container runs:

1
2
install -d -o www-data -g www-data -m 0755 /var/www/html/data
exec apache2-foreground

In local testing, this gave three clean guarantees:

  • /var/www/html/data initializes as www-data:www-data with mode 0755, so the web installer finishes without chmod 707.
  • data/dbconfig.php lives inside the gnuboard-data volume. Running docker compose down && docker compose up -d preserves the installed site and database, while docker compose down -v wipes both volumes and resets to the installer.
  • One small caveat: if data/ doesn’t exist on the host yet, Docker creates an empty data/ directory on the host as the mountpoint. No files get written there, and .gitignore already ignores data/, so git status stays clean.

For local email delivery, config.php reads environment variables with fallbacks to the original defaults:

1
2
3
4
// config.php (environment variable fallbacks)
define('G5_DOMAIN', getenv('G5_DOMAIN') ?: '');
define('G5_SMTP',      getenv('G5_SMTP') ?: '127.0.0.1');
define('G5_SMTP_PORT', getenv('G5_SMTP_PORT') ?: '25');

Existing non-Docker deployments keep their original defaults ('', '127.0.0.1', '25'), while the container automatically injects G5_DOMAIN, mailpit, and 1025. When checking config.php directly from the CLI, define $g5_path first to avoid an undefined variable warning:

1
2
3
4
5
# Inside the container (Compose env applied)
docker compose exec web php -r '$g5_path=["path"=>"."]; require "config.php"; echo G5_DOMAIN, " / ", G5_SMTP, ":", G5_SMTP_PORT, "\n";'

# With env vars cleared (verifying host fallback defaults)
docker compose exec -e G5_DOMAIN= -e G5_SMTP= -e G5_SMTP_PORT= web php -r '$g5_path=["path"=>"."]; require "config.php"; var_dump(G5_DOMAIN, G5_SMTP, G5_SMTP_PORT);'
1
2
3
4
5
6
7
# Inside the container (Compose env applied)
http://127.0.0.1:8080 / mailpit:1025

# With env vars cleared (fallback defaults)
string(0) ""
string(9) "127.0.0.1"
string(2) "25"

Setting G5_DOMAIN is required for security emails, not optional. When G5_DOMAIN is empty, g5_security_mail_base_url() returns false, and the security mail handler blocks the send and writes [g5 security mail] Valid G5_DOMAIN is required. to the PHP error log. With G5_DOMAIN populated (even after overriding GNUBOARD_WEB_PORT=18081 in .env), mailer() delivers through mailpit:1025 and the verification link inside the message matches the active port.

Mailpit web UI displaying a Gnuboard5 password reset test email with the local G5_DOMAIN link Figure 2. Mailpit v1.34.1 web UI showing a password-reset test email sent via mailpit:1025 in a local Docker Compose run with .env ports 18081 and 18026.

Reusing the stack in VS Code Dev Containers

To avoid maintaining two separate container definitions, .devcontainer/devcontainer.json points directly to ../compose.yaml:

1
2
3
4
5
6
7
8
9
10
// .devcontainer/devcontainer.json
{
    "name": "그누보드5",
    "dockerComposeFile": "../compose.yaml",
    "service": "web",
    "workspaceFolder": "/var/www/html",
    "remoteUser": "developer",
    "overrideCommand": false,
    "shutdownAction": "stopCompose"
}

Each key has a specific job:

  • overrideCommand: false: By default, Dev Containers replaces a Compose service’s command with sleep infinity. Setting this to false preserves install -d ... && exec apache2-foreground so Apache stays alive as PID 1.
  • remoteUser: "developer": Inside the container, Apache’s master process runs as root (PID 1) and its workers run as www-data (UID 33), while your interactive shell uses the non-root developer account (UID 1000, /bin/bash).
  • shutdownAction: "stopCompose": Closing the VS Code window stops web, db, and mailpit together instead of leaving background containers running.

Verification scope: Process separation (root/www-data vs developer UID 1000) and file writes to /var/www/html as developer were tested inside the container on macOS Docker Desktop (VirtioFS). VS Code GUI actions (Reopen in Container and window-close shutdownAction) and Linux host UID remapping (updateRemoteUserUID when the host UID isn’t 1000) weren’t executed via GUI in this CLI test and follow the official Dev Containers specification.

When not to use this setup and checklist

Pick the workflow that matches how your team edits and runs PHP code:

ApproachBest fitUpsideTrade-off
Host APM / HomebrewSolo work pinned to one PHP versionZero container overheadExtension drift, manual data/ resets, external SMTP setup
Docker Compose CLI (compose.yaml)Keeping your host IDE (PhpStorm, Vim) while isolating runtimeOne command for PHP, MariaDB, Mailpit; easy .env port swapsHost and container PHP CLI versions can diverge
VS Code Dev ContainerTeam onboarding and identical PHP CLI/Git toolingEveryone runs inside the same container image and shellInitial build time and VS Code Remote extension requirement

This compose.yaml and .devcontainer setup is strictly for local development and testing. Do not deploy it to production.

It breaks production security assumptions in four ways: the database password (gnuboard) is hardcoded in compose.yaml, G5_DOMAIN uses plain HTTP on 127.0.0.1, the entire repository is bind-mounted into Apache’s document root, and Mailpit intercepts all outgoing mail instead of delivering it. Production deployments need immutable built images, HTTPS behind a reverse proxy, secret management, and a real SMTP relay.

Before using this stack day to day, keep these five checks in mind:

  • If 8080, 3306, or 8025 is already in use, set GNUBOARD_WEB_PORT, GNUBOARD_DB_PORT, or GNUBOARD_MAILPIT_PORT in a root .env file instead of editing compose.yaml.
  • During the /install/ wizard, enter db (not localhost) as the database host, and gnuboard for the user, password, and database name.
  • Run docker compose down -v whenever you want a clean reinstall; plain docker compose down keeps both gnuboard-data and db-data.
  • Run docker compose build --pull web && docker compose up -d when pulling newer PHP 8.5 patch releases.
  • On native Linux hosts where your user UID isn’t 1000, verify file ownership on the bind mount if you run docker compose without VS Code’s updateRemoteUserUID.

References

그누보드5 (영카트 포함) 공개형 Git. Contribute to gnuboard/gnuboard5 development by creating an account on GitHub.
The devcontainer.json file contains any needed metadata and settings required to configure a development container for a given well-defined tool and runtime ...
Examples of how to run Mailpit within Docker
This post is licensed under CC BY 4.0 by the author.