Skip to content

Commit 43ba31f

Browse files
committed
Releasing 0.9.0
2 parents 6f82907 + 9f781fe commit 43ba31f

6 files changed

Lines changed: 296 additions & 16 deletions

File tree

Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
FROM eu.gcr.io/long-grin-186810/rs-php:7.4.4-apache-2.4.38.0
2-
MAINTAINER Ralph Schuster <github@ralph-schuster.eu>
2+
LABEL maintainer="Ralph Schuster <github@ralph-schuster.eu>"
3+
4+
#RUN apt-get update && apt-get update && apt-get install -y --no-install-recommends \
5+
# patch \
6+
# && rm -rf /var/lib/apt/lists/*
37

48
#ADD etc/php/ /usr/local/etc/php/conf.d/
59
#ADD etc/conf/ /etc/apache2/conf-enabled/
610
#ADD etc/mods/ /etc/apache2/mods-enabled/
711
#ADD etc/sites/ /etc/apache2/sites-enabled/
8-
ADD src/ /var/www/html/
912
RUN chown -R www-data:www-data /var/www/html
1013

11-
RUN cd /var/www/html \
12-
&& curl -o postfixadmin.tar.gz https://netcologne.dl.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-3.2/postfixadmin-3.2.tar.gz \
13-
&& tar --strip-components=1 -xzvf postfixadmin.tar.gz \
14+
ENV PFA_VERSION="3.2.4"
15+
ENV PFA_URL="https://github.com/postfixadmin/postfixadmin/archive/postfixadmin-${PFA_VERSION}.tar.gz"
16+
RUN set -xe \
17+
&& cd /var/www/html \
18+
&& curl -o postfixadmin.tar.gz -L "$PFA_URL" \
19+
&& tar --strip-components=1 -xvf postfixadmin.tar.gz \
1420
&& rm postfixadmin.tar.gz \
1521
&& mkdir templates_c \
1622
&& chown -R www-data:www-data .
1723

24+
ADD src/ /var/www/html/
1825

LICENSE.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
GNU Lesser General Public License
2+
=================================
3+
4+
_Version 3, 29 June 2007_
5+
6+
_Copyright © 2007 Free Software Foundation, Inc. [https://fsf.org/](https://fsf.org/)_
7+
8+
Everyone is permitted to copy and distribute verbatim copies
9+
of this license document, but changing it is not allowed.
10+
11+
12+
This version of the GNU Lesser General Public License incorporates
13+
the terms and conditions of version 3 of the GNU General Public
14+
License, supplemented by the additional permissions listed below.
15+
16+
### 0. Additional Definitions
17+
18+
As used herein, “this License” refers to version 3 of the GNU Lesser
19+
General Public License, and the “GNU GPL” refers to version 3 of the GNU
20+
General Public License.
21+
22+
“The Library” refers to a covered work governed by this License,
23+
other than an Application or a Combined Work as defined below.
24+
25+
An “Application” is any work that makes use of an interface provided
26+
by the Library, but which is not otherwise based on the Library.
27+
Defining a subclass of a class defined by the Library is deemed a mode
28+
of using an interface provided by the Library.
29+
30+
A “Combined Work” is a work produced by combining or linking an
31+
Application with the Library. The particular version of the Library
32+
with which the Combined Work was made is also called the “Linked
33+
Version”.
34+
35+
The “Minimal Corresponding Source” for a Combined Work means the
36+
Corresponding Source for the Combined Work, excluding any source code
37+
for portions of the Combined Work that, considered in isolation, are
38+
based on the Application, and not on the Linked Version.
39+
40+
The “Corresponding Application Code” for a Combined Work means the
41+
object code and/or source code for the Application, including any data
42+
and utility programs needed for reproducing the Combined Work from the
43+
Application, but excluding the System Libraries of the Combined Work.
44+
45+
### 1. Exception to Section 3 of the GNU GPL
46+
47+
You may convey a covered work under sections 3 and 4 of this License
48+
without being bound by section 3 of the GNU GPL.
49+
50+
### 2. Conveying Modified Versions
51+
52+
If you modify a copy of the Library, and, in your modifications, a
53+
facility refers to a function or data to be supplied by an Application
54+
that uses the facility (other than as an argument passed when the
55+
facility is invoked), then you may convey a copy of the modified
56+
version:
57+
58+
* **a)** under this License, provided that you make a good faith effort to
59+
ensure that, in the event an Application does not supply the
60+
function or data, the facility still operates, and performs
61+
whatever part of its purpose remains meaningful, or
62+
63+
* **b)** under the GNU GPL, with none of the additional permissions of
64+
this License applicable to that copy.
65+
66+
### 3. Object Code Incorporating Material from Library Header Files
67+
68+
The object code form of an Application may incorporate material from
69+
a header file that is part of the Library. You may convey such object
70+
code under terms of your choice, provided that, if the incorporated
71+
material is not limited to numerical parameters, data structure
72+
layouts and accessors, or small macros, inline functions and templates
73+
(ten or fewer lines in length), you do both of the following:
74+
75+
* **a)** Give prominent notice with each copy of the object code that the
76+
Library is used in it and that the Library and its use are
77+
covered by this License.
78+
* **b)** Accompany the object code with a copy of the GNU GPL and this license
79+
document.
80+
81+
### 4. Combined Works
82+
83+
You may convey a Combined Work under terms of your choice that,
84+
taken together, effectively do not restrict modification of the
85+
portions of the Library contained in the Combined Work and reverse
86+
engineering for debugging such modifications, if you also do each of
87+
the following:
88+
89+
* **a)** Give prominent notice with each copy of the Combined Work that
90+
the Library is used in it and that the Library and its use are
91+
covered by this License.
92+
93+
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
94+
document.
95+
96+
* **c)** For a Combined Work that displays copyright notices during
97+
execution, include the copyright notice for the Library among
98+
these notices, as well as a reference directing the user to the
99+
copies of the GNU GPL and this license document.
100+
101+
* **d)** Do one of the following:
102+
- **0)** Convey the Minimal Corresponding Source under the terms of this
103+
License, and the Corresponding Application Code in a form
104+
suitable for, and under terms that permit, the user to
105+
recombine or relink the Application with a modified version of
106+
the Linked Version to produce a modified Combined Work, in the
107+
manner specified by section 6 of the GNU GPL for conveying
108+
Corresponding Source.
109+
- **1)** Use a suitable shared library mechanism for linking with the
110+
Library. A suitable mechanism is one that **(a)** uses at run time
111+
a copy of the Library already present on the user's computer
112+
system, and **(b)** will operate properly with a modified version
113+
of the Library that is interface-compatible with the Linked
114+
Version.
115+
116+
* **e)** Provide Installation Information, but only if you would otherwise
117+
be required to provide such information under section 6 of the
118+
GNU GPL, and only to the extent that such information is
119+
necessary to install and execute a modified version of the
120+
Combined Work produced by recombining or relinking the
121+
Application with a modified version of the Linked Version. (If
122+
you use option **4d0**, the Installation Information must accompany
123+
the Minimal Corresponding Source and Corresponding Application
124+
Code. If you use option **4d1**, you must provide the Installation
125+
Information in the manner specified by section 6 of the GNU GPL
126+
for conveying Corresponding Source.)
127+
128+
### 5. Combined Libraries
129+
130+
You may place library facilities that are a work based on the
131+
Library side by side in a single library together with other library
132+
facilities that are not Applications and are not covered by this
133+
License, and convey such a combined library under terms of your
134+
choice, if you do both of the following:
135+
136+
* **a)** Accompany the combined library with a copy of the same work based
137+
on the Library, uncombined with any other library facilities,
138+
conveyed under the terms of this License.
139+
* **b)** Give prominent notice with the combined library that part of it
140+
is a work based on the Library, and explaining where to find the
141+
accompanying uncombined form of the same work.
142+
143+
### 6. Revised Versions of the GNU Lesser General Public License
144+
145+
The Free Software Foundation may publish revised and/or new versions
146+
of the GNU Lesser General Public License from time to time. Such new
147+
versions will be similar in spirit to the present version, but may
148+
differ in detail to address new problems or concerns.
149+
150+
Each version is given a distinguishing version number. If the
151+
Library as you received it specifies that a certain numbered version
152+
of the GNU Lesser General Public License “or any later version”
153+
applies to it, you have the option of following the terms and
154+
conditions either of that published version or of any later version
155+
published by the Free Software Foundation. If the Library as you
156+
received it does not specify a version number of the GNU Lesser
157+
General Public License, you may choose any version of the GNU Lesser
158+
General Public License ever published by the Free Software Foundation.
159+
160+
If the Library as you received it specifies that a proxy can decide
161+
whether future versions of the GNU Lesser General Public License shall
162+
apply, that proxy's public statement of acceptance of any version is
163+
permanent authorization for you to choose that version for the
164+
Library.
165+

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# docker-mailserver-postfixadmin
2+
This is a Docker image for a PostfixAdmin WebUI. The project is part of the
3+
[docker-mailserver](https://github.com/technicalguru/docker-mailserver) project but can run separately
4+
without the other components. However, a database server is always required to store structural data.
5+
6+
Related images:
7+
* [docker-mailserver](https://github.com/technicalguru/docker-mailserver) - The main project, containing composition instructions
8+
* [docker-mailserver-postfix](https://github.com/technicalguru/docker-mailserver-postfix) - Postfix/Dovecot image (mailserver component)
9+
* [docker-mailserver-amavis](https://github.com/technicalguru/docker-mailserver-amavis) - Amavis, ClamAV and SpamAssassin (provides spam and virus detection)
10+
* [docker-mailserver-roundcube](https://github.com/technicalguru/docker-mailserver-roundcube) - Roundcube Webmailer
11+
12+
# Tags
13+
The following versions are available from DockerHub. The image tag matches the PostfixAdmin version.
14+
15+
* [3.2.4-01, 3.2.4, 3.2, 3, latest](https://hub.docker.com/repository/docker/technicalguru/mailserver-postfixadmin) - [Dockerfile](https://github.com/technicalguru/docker-mailserver-postfixadmin/blob/3.2.4-01/Dockerfile)
16+
17+
# Features
18+
* Database and PostfixAdmin setup from environment variables
19+
20+
# License
21+
_docker-mailserver-postfixadmin_ is licensed under [GNU LGPL 3.0](LICENSE.md). As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
22+
23+
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
24+
25+
# Prerequisites
26+
The following components must be available at runtime:
27+
* [MySQL >8.0](https://hub.docker.com/\_/mysql) or [MariaDB >10.4](https://hub.docker.com/\_/mariadb) - used as database backend for domains and mailboxes.
28+
29+
# Usage
30+
31+
## Environment Variables
32+
_docker-mailserver-postfixadmin_ requires various environment variables to be set. The container startup will fail when the setup is incomplete.
33+
34+
| **Variable** | **Description** | **Default Value** |
35+
|------------|---------------|-----------------|
36+
| `PFA_SETUP_PASS` | The PostfixAdmin setup password. | |
37+
| `PFA_DB_HOST` | The hostname or IP address of the database server | |
38+
| `PFA_DB_USER` | The name of the database user. **Attention!** You shall not use an administrator account. | |
39+
| `PFA_DB_PASS` | The password of the database user | |
40+
| `PFA_DB_NAME` | The name of the database | |
41+
| `PFA_POSTFIX_SERVER` | The hostname of your SMTP server. Postfix requires this to send out initial e-mail for mailboxes. | |
42+
| `PFA_ABUSE_EMAIL` | E-mail address to be informed about abuses. | |
43+
| `PFA_HOSTMASTER_EMAIL` | E-mail address to be informed about issues with the host image. | |
44+
| `PFA_POSTMASTER_EMAIL` | E-mail address to be informed about mailbox and domain issues. | |
45+
| `PFA_WEBMASTER_EMAIL` | E-mail address to be informed about issues with the WebUI. | |
46+
47+
## Ports
48+
_docker-mailserver-postfixadmin_ exposes port 80 (the WebUI). No TLS support is built in. So you shall put your container behind an Ingress or Reverse Proxy that enforces HTTPS.
49+
50+
## Running the Container
51+
The [main mailserver project](https://github.com/technicalguru/docker-mailserver) has examples of container configurations:
52+
* [with docker-compose](https://github.com/technicalguru/docker-mailserver/tree/master/examples/docker-compose)
53+
* [with Kubernetes YAML files](https://github.com/technicalguru/docker-mailserver/tree/master/examples/kubernetes)
54+
* [with HELM charts](https://github.com/technicalguru/docker-mailserver/tree/master/helm-charts)
55+
56+
## Bootstrap and Setup
57+
Once you have started your PostfixAdmin container successfully, it is now time to perform the first-time setup for your mailserver. Open the web interface and navigate to `/public/setup.php`.
58+
59+
1. Enter the setup password as you provided it with environment variable `PFA_SETUP_PASS`.
60+
1. Create your PostfixAdmin administrator account. This is the main account to PostfixAdmin. It will enable you to create domains, mailboxes, aliases, etc.
61+
1. Login to PostfixAdmin by navigating to `/public/login.php`.
62+
1. Create your primary domain.
63+
1. Create your first mailbox in this domain.
64+
65+
# Additional PostfixAdmin customization
66+
You can further customize `config.inc.local.php`. Please follow these instructions:
67+
68+
1. Get a copy of the file from the `/var/www/html` folder.
69+
1. Customize your configuration file.
70+
1. Provide your customized file back into the `/var/www/html` by using a volume mapping.
71+
72+
# Issues
73+
This Docker image is mature and supports my own mailserver in production. There are no known issues at the moment.
74+
75+
76+
# Contribution
77+
Report a bug, request an enhancement or pull request at the [GitHub Issue Tracker](https://github.com/technicalguru/docker-mailserver-postfixadmin/issues).
78+

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: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,28 @@
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+
$PFA_SALT = md5(time() . '*' . $_SERVER['REMOTE_ADDR'] . '*' . mt_rand(0, 60000));
65+
$CONF['setup_password'] = $PFA_SALT.':'.sha1($PFA_SALT.':'.($_ENV['PFA_SETUP_PASS'] ? $_ENV['PFA_SETUP_PASS'] : $_ENV['PFA_DB_PASS']));
4866

4967
// Language config
5068
// Language files are located in './languages', change as required..
@@ -99,10 +117,10 @@ function language_hook($PALANG, $language) {
99117
// pgsql = PostgreSQL
100118
// sqlite = SQLite 3
101119
$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'];
120+
$CONF['database_host'] = $_ENV['PFA_DB_HOST'];
121+
$CONF['database_user'] = $_ENV['PFA_DB_USER'];
122+
$CONF['database_password'] = $_ENV['PFA_DB_PASS'];
123+
$CONF['database_name'] = $_ENV['PFA_DB_NAME'];
106124

107125
// Database SSL Config
108126
$CONF['database_use_ssl'] = false;
@@ -157,8 +175,8 @@ function language_hook($PALANG, $language) {
157175
// Mail Server
158176
// Hostname (FQDN) of your mail server.
159177
// This is used to send email to Postfix in order to create mailboxes.
160-
$CONF['smtp_server'] = 'postfix-service';
161-
$CONF['smtp_port'] = '25';
178+
$CONF['smtp_server'] = $_ENV{'PFA_POSTFIX_SERVER'};
179+
$CONF['smtp_port'] = isset($_ENV{'PFA_POSTFIX_PORT'}) ? $_ENV{'PFA_POSTFIX_PORT'} : 25;
162180

163181
// SMTP Client
164182
// Hostname (FQDN) of the server hosting Postfix Admin
@@ -234,10 +252,10 @@ function language_hook($PALANG, $language) {
234252
// a) a full mail address
235253
// b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain
236254
$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'
255+
'abuse' => $_ENV{'PFA_ABUSE_EMAIL'},
256+
'hostmaster' => $_ENV{'PFA_HOSTMASTER_EMAIL'},
257+
'postmaster' => $_ENV{'PFA_POSTMASTER_EMAIL'},
258+
'webmaster' => $_ENV{'PFA_WEBMASTER_EMAIL'}
241259
);
242260

243261
// Mailboxes

src/index.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>
3+
<title>Postfix Admin</title>
4+
<meta http-equiv="refresh" content= "0; url=public/index.php" />
5+
</head>
6+
<body>
7+
<p>The Postfix Admin directory layout changed.</p>
8+
<p>Please update your webserver config so that the DocumentRoot or Alias points to the directory "public".</p>
9+
</body>
10+
</html>
11+

0 commit comments

Comments
 (0)