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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottcove
Copy link

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:

  • DB_PATH: This will accept any of the following (relative to the container)
    • Full path, including the sqlite extension on the filename
    • Path with trailing slash (this will add mail.sqlite)
    • Path without trailing slash (This will add the slash and mail.sqlite to it)
  • SMTP_USER: This is the smtp username that the user wants.
  • SMTP_PASS: This is the smtp password that the user wants.
    • If both the username and password are given, then these will be used.
    • If only the username is given, this will be used without a password.
    • If only the password is given, this will use the default username smtp-user
    • If neither are given, no auth will be used.
  • HTTP_USER: This is the username that the user wants.
    • If both the username and password are given, then these will be used.
    • If only the username is given, this will be used without a password.
    • If only the password is given, this will use the default username admin
    • If neither are given, no auth will be used.
  • HTTP_PASS: This is the http password that the user wants.
  • DEBUG: Boolean that switches sendria debug on.
  • NO_QUIT: Boolean that switches -n on when true.
  • NO_CLEAR: Boolean that switches -c on when true.
  • TEMPLATE_NAME: Allows the user to set the name of the template
  • TEMPLATE_URL: Allows the user to set the url.
  • LOG_FILE: Accepts a full path to a logfile (inside the container). This is particularly handy if you want persistent logging.

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:

  • Explicitly use the root user for the commands that need it
  • Use bash instead of ash - this allows the BASH_REMATCH functions to work in the entrypoint script.
  • Install apache2-utils that allow us to generate htpasswd files.
  • Adding the SENDRIA_DATA_DIR environment variable, which is used in the script, to allow for changes if need be, and is handy for persistent volumes.
  • Adding the entrypoint script from the tools folder, and running that.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants