huan / docker-simple-mail-forwarder

Simplest and Smallest Email Forward Service based on Docker.
https://hub.docker.com/r/zixia/simple-mail-forwarder/
Apache License 2.0
544 stars 86 forks source link

Feat/add file config #119

Open jaydouble opened 1 year ago

jaydouble commented 1 year ago

added SMF_CONFIG_FILE variable to use a file for config. to add file, be creative, you can use a bind mount, but also a secret. A bit easier to read if you have more than one forward to make. Maybe also a bit less change for misstakes.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

huan commented 1 year ago

Dear @jaydouble , thank you very much for the contribution; the code looks good!

However, I think it would be better not to introduce another parameter for SMF, which might make it more complicated.

Could you please provide a helper script for loading the data from the file and outputting the string which can satisfy the SMF_CONFIG format?

It would be perfect like this:

$ export SMF_CONFIG=`./scripts/smf-config-file.sh smf.config`
# ...
jaydouble commented 1 year ago

Maybe better to let the user chose: If he doesn't want to have a file variable, he can use:

export SMF_CONFIG=$(cat smf.config)
docker run -e SMF_CONFIG ....

If he want to use a config file variable, like when using a docker swarm he can use:

version: "3.8"

volumes:
  config:

services:
  smf:
    image: zixia/simple-mail-forwarder
    volumes:
      - config:/config
    ports:
      - 25:25
    environment:
      SMF_CONFIG_FILE: "/config/forwards"