Skip to content

Commit 1573935

Browse files
committed
MAIL-5 Making the image configurable
1 parent 6f82907 commit 1573935

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t technicalguru/mailserver-postfixadmin:latest .

src/config.local.php

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,27 @@
4141
*/
4242
$CONF['configured'] = true;
4343

44+
$PFA_VARS = array('PFA_SETUP_PASS', 'PFA_DB_USER', 'PFA_DB_HOST', 'PFA_DB_PASS', 'PFA_DB_NAME', 'PFA_POSTFIX_SERVER', 'PFA_ABUSE_EMAIL', 'PFA_HOSTMASTER_EMAIL', 'PFA_POSTMASTER_EMAIL', 'PFA_WEBMASTER_EMAIL');
45+
$PFA_ERROR = false;
46+
foreach ($PFA_VARS AS $PFA_VAR) {
47+
if (!isset($_ENV[$PFA_VAR])) {
48+
$PFA_ERROR = true;
49+
break;
50+
}
51+
}
52+
if ($PFA_ERROR) {
53+
echo '<h1>Configuration Error</h1>You must set environment these variables:<ul>';
54+
foreach ($PFA_VARS AS $PFA_VAR) {
55+
echo '<li>'.$PFA_VAR.': '.(isset($_ENV[$PFA_VAR]) ? '<span style="color: green; font-weight: bold;">configured</span>' : '<span style="color: red; font-weight: bold;">missing</span>').'</li>';
56+
}
57+
echo '</ul>';
58+
exit(1);
59+
}
60+
4461
// In order to setup Postfixadmin, you MUST specify a hashed password here.
4562
// To create the hash, visit setup.php in a browser and type a password into the field,
4663
// on submission it will be echoed out to you as a hashed value.
47-
$CONF['setup_password'] = password_hash($_ENV['PFA_SETUP_PASS'] ? $_ENV['PFA_SETUP_PASS'] : $_ENV['PF_DB_PASS'], PASSWORD_DEFAULT);
64+
$CONF['setup_password'] = password_hash($_ENV['PFA_SETUP_PASS'] ? $_ENV['PFA_SETUP_PASS'] : $_ENV['PFA_DB_PASS'], PASSWORD_DEFAULT);
4865

4966
// Language config
5067
// Language files are located in './languages', change as required..
@@ -99,10 +116,10 @@ function language_hook($PALANG, $language) {
99116
// pgsql = PostgreSQL
100117
// sqlite = SQLite 3
101118
$CONF['database_type'] = 'mysqli';
102-
$CONF['database_host'] = $_ENV['PF_DB_HOST'];
103-
$CONF['database_user'] = $_ENV['PF_DB_USER'];
104-
$CONF['database_password'] = $_ENV['PF_DB_PASS'];
105-
$CONF['database_name'] = $_ENV['PF_DB_NAME'];
119+
$CONF['database_host'] = $_ENV['PFA_DB_HOST'];
120+
$CONF['database_user'] = $_ENV['PFA_DB_USER'];
121+
$CONF['database_password'] = $_ENV['PFA_DB_PASS'];
122+
$CONF['database_name'] = $_ENV['PFA_DB_NAME'];
106123

107124
// Database SSL Config
108125
$CONF['database_use_ssl'] = false;
@@ -157,8 +174,8 @@ function language_hook($PALANG, $language) {
157174
// Mail Server
158175
// Hostname (FQDN) of your mail server.
159176
// This is used to send email to Postfix in order to create mailboxes.
160-
$CONF['smtp_server'] = 'postfix-service';
161-
$CONF['smtp_port'] = '25';
177+
$CONF['smtp_server'] = $_ENV{'PFA_POSTFIX_SERVER'};
178+
$CONF['smtp_port'] = isset($_ENV{'PFA_POSTFIX_PORT'}) ? $_ENV{'PFA_POSTFIX_PORT'} : 25;
162179

163180
// SMTP Client
164181
// Hostname (FQDN) of the server hosting Postfix Admin
@@ -234,10 +251,10 @@ function language_hook($PALANG, $language) {
234251
// a) a full mail address
235252
// b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain
236253
$CONF['default_aliases'] = array (
237-
'abuse' => 'abuse@change-this-to-your.domain.tld',
238-
'hostmaster' => 'hostmaster@change-this-to-your.domain.tld',
239-
'postmaster' => 'postmaster@change-this-to-your.domain.tld',
240-
'webmaster' => 'webmaster@change-this-to-your.domain.tld'
254+
'abuse' => $_ENV{'PFA_ABUSE_EMAIL'},
255+
'hostmaster' => $_ENV{'PFA_HOSTMASTER_EMAIL'},
256+
'postmaster' => $_ENV{'PFA_POSTMASTER_EMAIL'},
257+
'webmaster' => $_ENV{'PFA_WEBMASTER_EMAIL'}
241258
);
242259

243260
// Mailboxes

0 commit comments

Comments
 (0)