Skip to content

Deploying a MantisBT App

Introduction

MantisBT is an open-source bug tracking and project management tool built on PHP. Deploying MantisBT with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for attachments and logs—all orchestrated from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample config, and production tips.


Prerequisites

  • A Klutch.sh account (create one)
  • A GitHub repository containing your MantisBT code/config (GitHub is the only supported git source)
  • Docker familiarity and PHP 8.1+ knowledge
  • Database credentials (MySQL/MariaDB)
  • Storage for attachments and logs

For onboarding, see the Quick Start.


Architecture and ports

  • MantisBT serves HTTP; set the internal container port to 8080.
  • MySQL/MariaDB should run as a separate Klutch.sh TCP app, exposed on port 8000 and connected internally on 3306.
  • Persistent storage is required for config/, plugins/, and files/.

Repository layout

mantisbt/
├── config/ # Custom configuration (mount as volume)
├── plugins/ # Optional plugins (mount as volume)
├── files/ # Attachments (mount as volume)
├── Dockerfile # Must be at repo root for auto-detection
├── composer.json
├── composer.lock
└── .env.example # Template only; no secrets

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Install dependencies and run locally before pushing to GitHub:

Terminal window
composer install --no-dev --optimize-autoloader
php -S 0.0.0.0:8080 -t .

Optional helper start.sh for portability and Nixpacks fallback:

#!/usr/bin/env bash
set -euo pipefail
php -S 0.0.0.0:8080 -t .

Make it executable with chmod +x start.sh.


Dockerfile for MantisBT (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM php:8.2-apache
RUN apt-get update && apt-get install -y \
libpng-dev libjpeg-dev libfreetype6-dev libzip-dev libicu-dev libxml2-dev libonig-dev git unzip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install pdo_mysql gd intl zip opcache \
&& a2enmod rewrite \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html
COPY . /var/www/html
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer install --no-dev --optimize-autoloader && \
chown -R www-data:www-data /var/www/html
ENV PORT=8080
EXPOSE 8080
CMD ["apache2-foreground"]

Notes:

  • Includes common PHP extensions required by MantisBT.
  • Ensure writable permissions for config/, plugins/, and files/.

Environment variables (Klutch.sh)

Set these in the Klutch.sh app settings (Secrets tab) before deploying:

  • PORT=8080
  • DB_HOST=<db-host>
  • DB_PORT=3306
  • DB_NAME=<db-name>
  • DB_USER=<db-user>
  • DB_PASSWORD=<db-password>
  • APP_URL=https://example-app.klutch.sh
  • DEFAULT_TIMEZONE=UTC

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_BUILD_CMD=composer install --no-dev --optimize-autoloader
  • NIXPACKS_START_CMD=php -S 0.0.0.0:8080 -t .
  • NIXPACKS_INSTALL_PKGS="php82 php82Extensions.pdo_mysql php82Extensions.intl php82Extensions.gd php82Extensions.zip"

These keep MantisBT compatible with Nixpacks defaults when a Dockerfile is absent.


Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /var/www/html/config — configuration.
  • /var/www/html/plugins — plugins if installed at runtime.
  • /var/www/html/files — attachments.

Ensure these paths are writable inside the container.


Deploy MantisBT on Klutch.sh (Dockerfile workflow)

  1. Push your repository (with the Dockerfile at the root) to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  1. Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
  2. Choose HTTP traffic for MantisBT.
  3. Set the internal port to 8080.
  4. Add the environment variables above (database settings, app URL, timezone, and any NIXPACKS_* overrides if you temporarily deploy without the Dockerfile).
  5. Attach persistent volumes for /var/www/html/config, /var/www/html/plugins, and /var/www/html/files, selecting sizes that fit your storage needs.
  6. Deploy. Your MantisBT instance will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

For MySQL/MariaDB on Klutch.sh, create a separate TCP app, expose it on port 8000, and point DB_HOST to that endpoint (internal port 3306).


Sample configuration snippet

Add to config/config_inc.php (values injected via env):

$g_hostname = getenv('DB_HOST');
$g_db_username = getenv('DB_USER');
$g_db_password = getenv('DB_PASSWORD');
$g_database_name = getenv('DB_NAME');

Health checks and production tips

  • Use a reverse proxy probe on / or /login_page.php for health monitoring.
  • Enforce HTTPS at the edge; forward HTTP to port 8080 internally.
  • Keep dependencies and image tags pinned; upgrade intentionally.
  • Monitor disk usage on files/ and resize before it fills.
  • Back up your database and attachments regularly; do not rely on container filesystems for durability.

MantisBT on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage for configuration/plugins/attachments, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and port 8080 configured, you can run a reliable issue tracker without extra YAML or workflow overhead.