Deploy Mailtrain With Docker
The steps below show you how to deploy a minimal Mailtrain server (an open source Mailchimp alternative) on Ubuntu 16.04 LTS. This will not be using a dockerized Redis or MySQL server so you can get by with just a 512MB RAM instance.
Requirements
- 768 MB of RAM
- A MySQL database (either locally or remote)
Steps
Make sure you are running the latest LTS kernel, and if not upgrade it.
Deploy a MySQL or MariaDB server (may or may not be on the same server). This will hold all of our "state" that will be kept across mailtrain deployments.
Download the latest release. At the time of writing this post, it is 1.24.0, but be sure to check and update the command below accordingly.
wget https://github.com/Mailtrain-org/mailtrain/archive/v1.24.0.tar.gz
tar --extract --gzip --file v1.24.0.tar.gz
rm v1.24.0.tar.gz
Navigate to within the mailtrain folder and build the image.
cd mailtrain-*
sudo docker build -t mailtrain-node:latest .
Navigate back home.
cd ~
Copy and paste the content below into a file called docker-compose.yml
.
version: '2' services: mailtrain-node: image: mailtrain-node:latest container_name: "mailtrain-node" restart: always ports: - "80:3000" volumes: - "./volumes/production.toml:/app/config/production.toml" - "./volumes/mailtrain-node-data:/app/public/grapejs/uploads" - "./volumes/mailtrain-node-data:/app/public/mosaico/uploads"
Create a folder called volumes.
mkdir volumes
Copy the default toml config file into your volumes folder to be used.
cp mailtrain/config/default.toml \
volumes/production.toml
Update MySQL credentials in the config file you just created.
editor production.toml
...
[mysql]
host="MYSQL_HOSTNAME"
user="mailtrain"
password="MYSQL_USER_PASSWORD"
database="mailtrain"
port=3306
charset="utf8mb4"
timezone="UTC"
...
[redis]
enabled=false
...
host
field for it to work with the docker container.
You will also need to ensure your MySQL server allows remote connections by commenting out the bind-address
line in the /etc/mysql/mysql.conf.d/mysqld.cnf
config file.
Now deploy the docker containers with:
docker-compose up -d
Conclusion
You now have a working mailtrain server. Be sure to open your web browser to the ip or hostname of your server and authenticate with admin
: test
before going to the settings area to change your login credentials, and plug in your SMTP or AWS SES credentials for sending emails.