Skip to content

Commit adf6cdb

Browse files
committed
feat: add SMTP vars, upgrade PHP and MySQL
1 parent d6c8ab4 commit adf6cdb

File tree

4 files changed

+73
-13
lines changed

4 files changed

+73
-13
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.4-apache
1+
FROM php:8.4-apache
22

33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44

@@ -43,7 +43,7 @@ RUN set -xe \
4343
COPY config_inc.php /var/www/html/config/config_inc.php
4444

4545
# Install additional plugins
46-
ENV SOURCE_TAG v2.5.2
46+
ENV SOURCE_TAG v2.9.0
4747
RUN set -xe && \
4848
curl -fSL https://github.com/mantisbt-plugins/source-integration/tarball/${SOURCE_TAG} -o /tmp/source.tar.gz && \
4949
mkdir /tmp/source && \

README.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are some other alternative images exist already such as [vimagick/mantisbt
1212
The reason is to combine all the useful features they have and add some missing ones. To list some:
1313

1414
- Always latest MantisBT version.
15-
- Comes with the latest PHP version (7.4 as for today)
15+
- Comes with the latest PHP version (8.4 as for today)
1616
- Allows to easily configure presence of `admin` service folder
1717
- Comes with built-in integration with Gitlab and Github [source plugins](https://github.com/mantisbt-plugins/source-integration)
1818
- Example `docker-compose.yml` file provided for getting started in one click!
@@ -34,7 +34,7 @@ https://www.mantisbt.org/docs/master/en-US/Admin_Guide/html-desktop/#admin.confi
3434

3535
For further details refer to [official documentation](https://www.mantisbt.org/docs/master/en-US/Admin_Guide/html-desktop/#admin.install.new)
3636

37-
# Example docker-compose.yml
37+
## Example docker-compose.yml
3838

3939
```YAML
4040
version: "3"
@@ -54,6 +54,12 @@ services:
5454
- EMAIL_WEBMASTER=webmaster@localhost
5555
- EMAIL_FROM=webmaster@localhost
5656
- EMAIL_RETURN_PATH=webmaster@localhost
57+
# SMTP Settings, below are default values
58+
#- SMTP_HOST=smtp.yourmail.com
59+
#- SMTP_USER=username
60+
#- SMTP_PASSWORD=superstrongpassword
61+
#- SMTP_PORT=587
62+
#- SMTP_MODE=tls # Maps to $g_smtp_connection_mode, defaults to tls, can be ssl or empty
5763
# Uncomment only if modified from default values
5864
#- MYSQL_HOST=db
5965
#- MYSQL_DATABASE=bugtracker
@@ -64,10 +70,10 @@ services:
6470
restart: always
6571

6672
db:
67-
image: mysql:5.7
73+
image: mysql:8.4
6874
container_name: mantis_db
6975
volumes:
70-
- ./db_data:/var/lib/mysql
76+
- ./db_data_v8:/var/lib/mysql
7177
environment:
7278
- MYSQL_ROOT_PASSWORD=root
7379
- MYSQL_DATABASE=bugtracker
@@ -77,6 +83,30 @@ services:
7783

7884
```
7985

86+
## Upgrading
87+
88+
Normally, you should be able to upgrade freely without any restrictions, just make sure to run the compose with `MANTIS_ENABLE_ADMIN=1` after updating the versions and go to `your-mantis-instance/admin` to perform database upgrades when needed. That's all :)
89+
90+
### MySQL 5.7 EOL
91+
92+
`docker-compose.yaml` file before May 2025 in this repo was using `mysql:5.7` as database container. This has became EOL in 2023, so it was updated to current LTS version 8.4. Unfortunately [MySQL does NOT support direct upgrade](https://dev.mysql.com/doc/refman/8.4/en/upgrade-paths.html), so the recommended way is to just backup the database, upgrade the version and set new path for `db_data`, then recreate the database from dump.
93+
94+
```
95+
# Backup first anyway
96+
docker exec mantis_db /usr/bin/mysqldump -u root -proot bugtracker > backup.sql
97+
docker compose down
98+
# Change 5.7->8.4 and either update db_data mount path e.g. to db_data_v8 or rename db_data->db_data.old
99+
docker compose up -d
100+
101+
docker cp backup.sql mantis_db:/backup.sql
102+
docker exec -it mantis_db bash
103+
# Inside container
104+
mysql -u root -p bugtracker < /backup.sql
105+
106+
# Test the instance, check /admin, if all good - set MANTIS_ENABLE_ADMIN=0 and enjoy
107+
108+
```
109+
80110
# Extensions
81111

82112
## Custom config settings
@@ -105,11 +135,21 @@ $g_anonymous_account = 'anonymous';
105135

106136
There are following env variables supported:
107137

108-
- EMAIL_WEBMASTER - maps to `g_webmaster_email`
109-
- EMAIL_FROM - maps to `g_from_email`
110-
- EMAIL_RETURN_PATH - maps to `g_return_path_email`
138+
- `EMAIL_WEBMASTER` - maps to `g_webmaster_email`
139+
- `EMAIL_FROM` - maps to `g_from_email`
140+
- `EMAIL_RETURN_PATH` - maps to `g_return_path_email`
141+
- `EMAIL_FROM_NAME` - maps to `$g_from_name`
142+
143+
Also SMTP env variables are supported as well:
144+
145+
- `SMTP_HOST=smtp.yourmail.com`
146+
- `SMTP_USER=username`
147+
- `SMTP_PASSWORD=superstrongpassword`
148+
- `SMTP_PORT=587`
149+
- `SMTP_MODE=tls` - Maps to $g_smtp_connection_mode, defaults to tls, can be ssl or empty
150+
```
111151
112-
Those are good enough to start with. Going further, to configure SMTP you might need to create custom config (as described above) with the values like:
152+
Those are good enough to start with. Going further, to configure more details you might need to create custom config (as described above) with the values like those:
113153
```
114154
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
115155
$g_smtp_host = 'mail.domain.com';

config_inc.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
# Configure email
1515
$g_webmaster_email = getenv('EMAIL_WEBMASTER') !== false ? getenv('EMAIL_WEBMASTER') : null;
1616
$g_from_email = getenv('EMAIL_FROM') !== false ? getenv('EMAIL_FROM') : null;
17+
if (getenv('EMAIL_FROM_NAME') !== false) {
18+
$g_from_name = getenv('EMAIL_FROM_NAME');
19+
}
1720
$g_return_path_email = getenv('EMAIL_RETURN_PATH') !== false ? getenv('EMAIL_RETURN_PATH') : null;
1821

22+
# SMTP
23+
if (getenv('SMTP_HOST') !== false) {
24+
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
25+
$g_smtp_host = getenv('SMTP_HOST');
26+
$g_smtp_port = getenv('SMTP_PORT') !== false ? getenv('SMTP_PORT') : 587;
27+
$g_smtp_connection_mode = getenv('SMTP_MODE') !== false ? getenv('SMTP_MODE') : "tls";
28+
$g_smtp_username = getenv('SMTP_USER') !== false ? getenv('SMTP_USER') : null;
29+
$g_smtp_password = getenv('SMTP_PASSWORD') !== false ? getenv('SMTP_PASSWORD') : null;
30+
}
31+
1932
include 'config_inc_addon.php';

docker-compose.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ services:
1212
- MANTIS_ENABLE_ADMIN=1
1313
# Set master salt, typically can be generated by `cat /dev/urandom | head -c 64 | base64`
1414
#- MASTER_SALT=
15-
# Set base email settings. For more detailed configuration (i.e. SMTP) you'll need to add own config file
15+
# Set base email settings. For more detailed configuration you'll need to add own config file
1616
- EMAIL_WEBMASTER=webmaster@localhost
1717
- EMAIL_FROM=webmaster@localhost
18+
- EMAIL_FROM_NAME=Mantis BT
1819
- EMAIL_RETURN_PATH=webmaster@localhost
20+
# SMTP Settings, below are default values
21+
#- SMTP_HOST=smtp.yourmail.com
22+
#- SMTP_USER=username
23+
#- SMTP_PASSWORD=superstrongpassword
24+
#- SMTP_PORT=587
25+
#- SMTP_MODE=tls # Maps to $g_smtp_connection_mode, defaults to tls, can be ssl or empty
1926
# Uncomment only if modified from default values
2027
#- MYSQL_HOST=db
2128
#- MYSQL_DATABASE=bugtracker
@@ -30,10 +37,10 @@ services:
3037
restart: always
3138

3239
db:
33-
image: mysql:5.7
40+
image: mysql:8.4
3441
container_name: mantis_db
3542
volumes:
36-
- ./db_data:/var/lib/mysql
43+
- ./db_data_v8:/var/lib/mysql
3744
environment:
3845
# You might want to change root password before first run
3946
- MYSQL_ROOT_PASSWORD=root

0 commit comments

Comments
 (0)