msztolcman / sendria

Sendria (formerly MailTrap) is a SMTP server designed to run in your dev/test environment, that is designed to catch any email you or your application is sending, and display it in a web interface instead of sending to real world.
MIT License
149 stars 14 forks source link

Added options to dockerfile to allow for use of commandline options #12

Open scottcove opened 2 years ago

scottcove commented 2 years ago

Hi there!

I was in need of using multiple Sendria instances with auth inside of a dockerised, environment, so created a new endpoint script that allows the use of the command line options by passing certain environment variables to the container. The entrypoint script will then build the sendria command that needs running, and run it.

This allows for the following environment variables to be passed to the container:

Note that all of these are optional. If none are given, the same command is run as is currently run in master.

To make this work, the following changes were made to the Dockerfile:

This should greatly improve the usability of the docker container, and with all of the data in one directory, allows for persistence if the user so wishes.

An example docker command would be as below (I've built this as sendria:latest on my local):

docker run -d --restart unless-stopped --name sendria-project -p 1080:1080 -p 1025:1025 -v /usr/local/sendria/project/:/home/sendria/data -e HTTP_PASS="4secur3p@ssw0rd!" -e SMTP_USER="project-user" -e SMTP_PASS="4secur3p@ssw0rd!" -e NO_QUIT="TRUE" -e LOG_FILE="/home/sendria/data/log.log" -e TEMPLATE_NAME="My Projects Sendria Sinkhole" -e TEMPLATE_URL="http://172.25.1.174:1080" sendria:latest

Note that the above uses the default database location, assumes that the http user is admin, and allows the user to clear the mail, but not stop (exit) the container.

Thanks for considering this PR!