Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move basic enviroment variables into a configuration file #650

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Please set these as explained in README.md
SERVE_FROM_DOMAIN=
MAILMAN_ADMIN_USER=
MAILMAN_ADMIN_EMAIL=

# only use URL safe characters for the secrets, else you will break at least the DATABASE_URL
# i.e. do not use blanks ; / ? : @ = & < > # % { } | \ ^ ~ [ ] `
# you can use a commandline like `openssl rand -hex 24` to generate pseudo-random values for these secrets
HYPERKITTY_API_KEY=
DATABASE_PASSWORD=
DJANGO_SECRET_KEY=

# you might want to change the timezone to your local one
TZ=UTC

# likely, you don't need to change these:
DATABASE_NAME=mailmandb
DATABASE_USER=mailman
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
*/.sass-cache/*
*.log
*.log
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ For other systems, you can read the official Docker documentation to install

## Configuration

Most of the common configuration is handled through environment variables in the
`docker-compose.yaml`. However, there is need for some extra configuration that
Most of the common configuration is defined in `.env`. Please copy the content of `.env.example`
into a fresh `.env` file (i.e. by running `cp -a .env.example .env`) and customise it there.
Further custom environment variables should be set via a newly created docker-compose.override.yaml.

Additionally, there is need for some extra configuration that
interacts directly with the application. There are two configuration files on
the host that interact directly with Mailman's settings. These files exist on
the host running the containers and are imported at runtime in the containers.
Expand Down Expand Up @@ -151,7 +154,7 @@ mounted inside the containers.
container.

### Mailman-web
These are the settings that you MUST change in your docker-compose.yaml before deploying:
These are the settings that you MUST change in your `.env` before deploying:

- `SERVE_FROM_DOMAIN`: The domain name from which Django will be served. To be
added to `ALLOWED_HOSTS` in django settings. Default value is not set. This
Expand Down Expand Up @@ -190,7 +193,7 @@ For more details on how to configure this image, please look at

### Mailman-Core

These are the variables that you MUST change in your docker-compose.yaml before deploying:
These are the variables that you MUST change in your `.env` before deploying:

- `HYPERKITTY_API_KEY`: Hyperkitty's API Key, should be set to the same value as
set for the mailman-web. Skip the variable in case of non-Hyperkitty deployment.
Expand Down
20 changes: 11 additions & 9 deletions docker-compose-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ services:
- database:database
depends_on:
- database
environment:
- DATABASE_URL=mysql+pymysql://mailman:mailmanpass@database/mailmandb?charset=utf8mb4&use_unicode=1 # Do use mysql+pymysql:// here
environment: #
- DATABASE_URL=mysql+pymysql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}?charset=utf8mb4&use_unicode=1 # Do use mysql+pymysql:// here
- DATABASE_TYPE=mysql
- HYPERKITTY_API_KEY=someapikey
- HYPERKITTY_API_KEY=${HYPERKITTY_API_KEY}
- TZ=${TZ}
ports:
- "127.0.0.1:8001:8001" # API
- "127.0.0.1:8024:8024" # LMTP - incoming emails
Expand All @@ -37,10 +38,11 @@ services:
- /opt/mailman/web:/opt/mailman-web-data
environment:
- DATABASE_TYPE=mysql
- DATABASE_URL=mysql://mailman:mailmanpass@database/mailmandb?charset=utf8mb4 # Do use mysql:// here
- HYPERKITTY_API_KEY=someapikey
- SECRET_KEY=thisisaverysecretkey
- mysql+pymysql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}?charset=utf8mb4 # Do use mysql:// here
- HYPERKITTY_API_KEY=${HYPERKITTY_API_KEY}
- SECRET_KEY=${DJANGO_SECRET_KEY}
- DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
- TZ=${TZ}
ports:
- "127.0.0.1:8000:8000" # HTTP
- "127.0.0.1:8080:8080" # uwsgi
Expand All @@ -49,9 +51,9 @@ services:

database:
environment:
MYSQL_DATABASE: mailmandb
MYSQL_USER: mailman
MYSQL_PASSWORD: mailmanpass
MYSQL_DATABASE: ${DATABASE_NAME}
MYSQL_USER: ${DATABASE_USER}
MYSQL_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
image: mariadb:10.5
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
Expand Down
16 changes: 9 additions & 7 deletions docker-compose-postorius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ services:
depends_on:
- database
environment:
- DATABASE_URL=postgres://mailman:mailmanpass@database/mailmandb
- DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}
- DATABASE_TYPE=postgres
- DATABASE_CLASS=mailman.database.postgresql.PostgreSQLDatabase
- TZ=${TZ}
ports:
- "127.0.0.1:8001:8001" # API
- "127.0.0.1:8024:8024" # LMTP - incoming emails
Expand All @@ -36,10 +37,11 @@ services:
volumes:
- /opt/mailman/web:/opt/mailman-web-data
environment:
- DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}
- DATABASE_TYPE=postgres
- DATABASE_URL=postgres://mailman:mailmanpass@database/mailmandb
- SECRET_KEY=ksjdbaksdba
- UWSGI_STATIC_MAP=/static=/opt/mailman-web-data/static
- SECRET_KEY=${DJANGO_SECRET_KEY}
- UWSGI_STATIC_MAP=/static=/opt/mailman-web-data/static
- TZ=${TZ}
ports:
- "127.0.0.1:8000:8000" # HTTP
- "127.0.0.1:8080:8080" # uwsgi
Expand All @@ -48,9 +50,9 @@ services:

database:
environment:
POSTGRES_DB: mailmandb
POSTGRES_USER: mailman
POSTGRES_PASSWORD: mailmanpass
- POSTGRES_DB=${DATABASE_NAME}
- POSTGRES_USER=${DATABASE_USER}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
restart: always
image: postgres:9.6-alpine
volumes:
Expand Down
18 changes: 14 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ services:
database:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://mailman:mailmanpass@database/mailmandb
- DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}
- DATABASE_TYPE=postgres
- DATABASE_CLASS=mailman.database.postgresql.PostgreSQLDatabase
- HYPERKITTY_API_KEY=someapikey
- HYPERKITTY_API_KEY=${HYPERKITTY_API_KEY}
- TZ=${TZ}
ports:
- "127.0.0.1:8001:8001" # API
- "127.0.0.1:8024:8024" # LMTP - incoming emails
Expand All @@ -39,9 +40,14 @@ services:
volumes:
- /opt/mailman/web:/opt/mailman-web-data
environment:
- DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@database/${DATABASE_NAME}
- DATABASE_TYPE=postgres
- DATABASE_URL=postgresql://mailman:mailmanpass@database/mailmandb
- HYPERKITTY_API_KEY=someapikey
- HYPERKITTY_API_KEY=${HYPERKITTY_API_KEY}
- SECRET_KEY=${DJANGO_SECRET_KEY}
- TZ=${TZ}
- SERVE_FROM_DOMAIN=${SERVE_FROM_DOMAIN}
- MAILMAN_ADMIN_USER=${MAILMAN_ADMIN_USER}
- MAILMAN_ADMIN_EMAIL=${MAILMAN_ADMIN_EMAIL}
ports:
- "127.0.0.1:8000:8000" # HTTP
- "127.0.0.1:8080:8080" # uwsgi
Expand All @@ -50,6 +56,10 @@ services:

database:
environment:
- POSTGRES_DB=${DATABASE_NAME}
- POSTGRES_USER=${DATABASE_USER}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
image: postgres:11-alpine
- POSTGRES_DB=mailmandb
- POSTGRES_USER=mailman
- POSTGRES_PASSWORD=mailmanpass
Expand Down