← Back to DAGDA | Support | Source: https://github.com/xlrl/docker-mantisbt
Skip to content

About

No description, website, or topics provided.

Resources

Stars

50 stars

Watchers

5 watching

Forks

Repository files navigation

Docker image for MantisBT

Docker Pulls Docker Image Version Docker Image Size MantisBT PHP GitHub Tag License: MIT

MantisBT is an open source issue tracker that provides a delicate balance between simplicity and power.

The image is based on Alpine Linux with Apache and the distribution's prebuilt PHP packages, so no compiler is needed.

For changes take a look at Changelog.md.

Example docker-compose.yml

The examples suppose you will have the data for your containers in /srv/mantis. Adapt for your server.

Note: make sure the credentials in the "docker-compose.yml" environment variables match this you supply in "install.php".

services:
    mantisbt:
        image: xlrl/mantisbt:latest
        environment:
            MANTIS_TIMEZONE: Europe/Berlin
            MANTIS_ENABLE_ADMIN: 0
        ports:
            - "8989:80"
        volumes:
            - ./config:/var/www/html/config
            - ./custom:/var/www/html/custom
        restart: always

    mysql:
        image: mariadb:latest
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?Set MYSQL_ROOT_PASSWORD in the environment or a .env file}
            MYSQL_DATABASE: bugtracker
            MYSQL_USER: mantisbt
            MYSQL_PASSWORD: ${MYSQL_PASSWORD:?Set MYSQL_PASSWORD in the environment or a .env file}
        volumes:
            - ./mysql:/var/lib/mysql
        restart: always

You can use mysql/postgres instead of mariadb.

Install

Important: To be able to reach the "admin" directory, this has to be enabled with "MANTIS_ENABLE_ADMIN=1"

$ firefox http://localhost:8989/admin/install.php
>>> username: administrator
>>> password: root
==================================================================================
Installation Options
==================================================================================
Type of Database                                        MySQL/MySQLi
Hostname (for Database Server)                          mysql
Username (for Database)                                 mantisbt
Password (for Database)                                 the MYSQL_PASSWORD you set
Database name (for Database)                            bugtracker
Admin Username (to create Database if required)         root
Admin Password (to create Database if required)         the MYSQL_ROOT_PASSWORD you set
Print SQL Queries instead of Writing to the Database    [ ]
Attempt Installation                                    [Install/Upgrade Database]
==================================================================================

Permissions for config and custom

The ./config and ./custom folders are bind-mounted into the container, where the web server runs as www-data (uid 33, gid 33). When the installer fails with "Cannot write config_inc.php", the mounted folders are not writable by that user. Create them if they don't exist yet and fix the ownership on the host (deliberately not done automatically at container start):

mkdir -p ./config ./custom
chown -R 33:33 ./config ./custom

Email

Append following to /srv/mantis/config/config_inc.php

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_administrator_email = 'admin@example.org';
$g_webmaster_email = 'webmaster@example.org';
$g_return_path_email = 'mantisbt@example.org';
$g_from_email = 'mantisbt@example.org';
$g_smtp_host = 'smtp.example.org';
$g_smtp_port = 25;
$g_smtp_connection_mode = 'tls';
$g_smtp_username = 'mantisbt';
$g_smtp_password = '********';

LDAP

Append following to /srv/mantis/config/config_inc.php for LDAP authentication against an Active Directory server:

$g_login_method = LDAP;
$g_ldap_server = 'ldap://dc.example.com';
$g_ldap_root_dn = 'dc=example,dc=com';
$g_ldap_bind_dn = 'cn=readuser, dc=example, dc=com';
$g_ldap_bind_passwd = 'geheim123';
$g_ldap_organization = '';
$g_use_ldap_email = ON;
$g_use_ldap_realname = ON;
$g_ldap_protocol_version = 3;
$g_ldap_follow_referrals = OFF;
$g_ldap_uid_field = 'sAMAccountName';

Upload size

The php upload limit is set via PHP_MAX_UPLOAD_SIZE (default 5M) and matches the mantis default $g_max_file_size of 5MB. When changing one, adapt the other, otherwise the setup check reports an error. For example, for a limit of 2MB:

$g_max_file_size = 2 * 1024 * 1024;

The php setting allows shortcuts for byte values, including K (kilo), M (mega) and G (giga). Calculations like the example above won't work for the php parameter. There is a dependency between upload_max_filesize and post_max_size (default 8MB). PHP_MAX_UPLOAD_SIZE may not be set higher than 8M, otherwise further php config is necessary.

Reverse proxy and base path

Mantis derives its base URL from the request headers unless $g_path is set. Set it in config/config_inc.php to the public URL, including the trailing slash. This also silences the "path" is defined in config_inc.php warning of the setup check (admin/check/index.php):

$g_path = 'https://example.org/mantis/';

The container serves mantis at /, so the reverse proxy has to strip the path prefix, e.g. for Apache:

ProxyPass        /mantis/ http://localhost:8989/
ProxyPassReverse /mantis/ http://localhost:8989/
RequestHeader    set X-Forwarded-Proto "https"

or for nginx:

location /mantis/ {
    proxy_pass http://localhost:8989/;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
}

X-Forwarded-Proto lets mantis detect HTTPS, e.g. for secure cookies.

Setup check

The image is configured so that the setup check reports as few warnings as possible. The remaining warnings are expected:

  • "path" is defined in config_inc.php: set $g_path, see above.
  • ... is set to a path outside the web root for core_path, library_path, etc.: these folders are protected by .htaccess files.

Building

Build a multi-arch image (linux/amd64, linux/arm64) with podman, tagged localhost/xlrl/mantisbt:<MANTIS_VER> and localhost/xlrl/mantisbt:latest. With an argument, the image is tagged with this tag only:

./build-image.sh
./build-image.sh test
PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7 ./build-image.sh

Cross builds need qemu-user-static.

The script downloads and verifies the MantisBT tarball once into cache/, the build itself needs no network for it. A plain podman build needs this tarball in cache/ too.

Maintainers

This is the maintainer's section for this repository.

If you want to upgrade to a new mantis version X.Y.Z run the script update-dockerfile.py:

uv run update-dockerfile.py --mantis-version X.Y.Z

This will update the link and sha hash for the mantisbt source tarball. It also updates the Alpine base image to the latest stable branch and the PHP packages to the newest phpXY of that branch (skip with --keep-base-version).

Build the new image:

./build-image.sh

Run the image on your system or some test machine. Once you are satisfied with your tests, push both tags:

podman login <registry>
podman manifest push --all localhost/xlrl/mantisbt:X.Y.Z docker://<registry>/xlrl/mantisbt:X.Y.Z
podman manifest push --all localhost/xlrl/mantisbt:latest docker://<registry>/xlrl/mantisbt:latest

Also do not forget the git commit and tags:

git add Dockerfile
git commit -m "Update to X.Y.Z"
git tag X.Y.Z
git push origin/main X.Y.Z

This should be all!

About

No description, website, or topics provided.

Resources

Stars

50 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages