Skip to content

Commit 7b52038

Browse files
author
root
committed
Updates in install scripts
1 parent 3f4044c commit 7b52038

10 files changed

+183
-91
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ node_modules
55
npm-debug.log
66
.DS_Store
77
dump.rdb
8-
docker-compose.override.yml
98

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changelog
22

3-
## 2.0.0 2018-11-23
3+
## 2.0.0-rc1 2018-12-25
44

55
* This is a complete rewrite of Mailtrain v1 with many features added. Just check it out.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
FROM node:10.14-jessie
22

3+
RUN apt-get update && apt-get install -y pwgen netcat
4+
35
# First install dependencies
4-
COPY ../server/package.json ./app/server
5-
COPY ../client/package.json ./app/client
6-
COPY ../shared/package.json ./app/shared
7-
COPY ../zone-mta/package.json ./app/zone-mta
6+
COPY server/package.json /app/server/package.json
7+
COPY client/package.json /app/client/package.json
8+
COPY shared/package.json /app/shared/package.json
9+
COPY zone-mta/package.json /app/zone-mta/package.json
810

911
WORKDIR /app/
1012

11-
ENV NODE_ENV production
12-
1313
RUN for idx in client shared server zone-mta; do (cd $idx && npm install); done
1414

1515
# Later, copy the app files. That improves development speed as buiding the Docker image will not have
1616
# to download and install all the NPM dependencies every time there's a change in the source code
17-
COPY .. /app
17+
COPY . /app
1818

1919
RUN cd client && npm run build
2020

21-
EXPOSE 3000
22-
ENTRYPOINT ["bash", "/app/docker/docker-entrypoint.sh"]
21+
EXPOSE 3000 3003 3004
22+
ENTRYPOINT ["bash", "/app/docker-entrypoint.sh"]

README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
* Automation (triggered and RSS campaigns)
1515
* Multiple users with granular user permissions and flexible sharing
1616
* Hierarchical namespaces for enterprise-level situations
17+
* Builtin Zone-MTA (https://github.com/zone-eu/zone-mta) for close-to-zero setup of mail delivery
18+
19+
## Recommended minimal hardware Requirements
20+
* 2 vCPU
21+
* 4096 MB RAM
1722

18-
## Hardware Requirements
19-
* 1 vCPU
20-
* 2048 MB RAM
2123

2224
## Quick Start
2325

@@ -34,7 +36,6 @@ The recommended deployment of Mailtrain would use 3 DNS entries that all points
3436
- *sbox.mailtrain.example.com* - sandbox endpoint (CNAME record `sbox.mailtrain` under `example.com` domain that points to `lists`)
3537

3638

37-
3839
### Installation on fresh CentOS 7 or Ubuntu 18.04 LTS (public website secured by SSL)
3940

4041
This will setup a publicly accessible Mailtrain instance. All endpoints (trusted, sandbox, public) will provide both HTTP (on port 80)
@@ -54,14 +55,14 @@ Thus, by running this script below, you agree with the Let's Encrypt's Terms of
5455
sudo su -
5556
```
5657
57-
2. Install git
58+
2. Install GIT
5859
5960
For Centos 7 type:
6061
```
6162
yum install -y git
6263
```
6364
64-
For Ubuntu 18.04 LTS type:
65+
For Ubuntu 18.04 LTS type
6566
```
6667
apt-get install -y git
6768
```
@@ -162,23 +163,43 @@ All endpoints (trusted, sandbox, public) will provide only HTTP as follows:
162163
163164
164165
165-
## Quick Start - Deploy with Docker
166-
#### Requirements:
166+
### Deployment with Docker and Docker compose
167+
168+
This setup starts a stack composed of Mailtrain, MongoDB, Redis, and MariaDB. It will setup a locally accessible Mailtrain instance with HTTP endpoints as follows.
169+
- http://localhost:3000 - trusted endpoint
170+
- http://localhost:3003 - sandbox endpoint
171+
- http://localhost:3004 - public endpoint
172+
173+
To make this publicly accessible, you should add reverse proxy that makes these endpoints publicly available over HTTPS.
174+
175+
To deploy Mailtrain with Docker, you need the following three dependencies installed:
176+
177+
- [Docker](https://www.docker.com/)
178+
- [Docker Compose](https://docs.docker.com/compose/)
179+
- Git - Typically already present. If not, just use the package manager of your OS distribution to install it.
180+
181+
These are the steps to start Mailtrain via docker-compose:
167182
168-
* [Docker](https://www.docker.com/)
169-
* [Docker Compose](https://docs.docker.com/compose/)
183+
1. Download Mailtrain using git
184+
```
185+
git clone https://github.com/Mailtrain-org/mailtrain.git
186+
cd mailtrain
187+
git checkout development
188+
```
189+
190+
2. Deploy Mailtrain via docker-compose (in the root directory of the Mailtrain project). This will take quite some time when run for the first time. Subsequent executions will be fast.
191+
```
192+
docker-compose up
193+
```
194+
195+
You can specify Mailtrain's URL bases via the `MAILTRAIN_SETTINGS` environment variable as follows. The `--withProxy` parameter is to be used when Mailtrain is put behind a reverse proxy.
196+
```
197+
MAILTRAIN_SETTINGS="--trustedUrlBase https://mailtrain.example.com --sandboxUrlBase https://sbox.mailtrain.example.com --publicUrlBase https://lists.example.com --withProxy" docker-compose up
198+
```
170199
171-
#### Steps:
172-
Depending on how you have configured your system and Docker you may need to prepend the commands below with `sudo`.
200+
3. Open the trusted endpoint http://localhost:3000
173201
174-
* Download Mailtrain files using git: `git clone git://github.com/Mailtrain-org/mailtrain.git` (or download [zipped repo](https://github.com/Mailtrain-org/mailtrain/archive/master.zip)) and open Mailtrain folder `cd mailtrain`
175-
* Copy the file `docker-compose.override.yml.tmpl` to `docker-compose.override.yml` and modify it if you need to.
176-
* Bring up the stack with: `docker-compose up -d`
177-
* Start: `docker-compose start`
178-
* Open [http://localhost:3000/](http://localhost:3000/) (change the host name `localhost` to the name of the host where you are deploying the system).
179-
* Authenticate as user `admin` with password `test`
180-
* Navigate to [http://localhost:3000/settings](http://localhost:3000/settings) and update service configuration.
181-
* Navigate to [http://localhost:3000/users/account](http://localhost:3000/users/account) and update user information and password.
202+
4. Authenticate as `admin`:`test`
182203
183204
184205
## License

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3'
2+
3+
services:
4+
mysql:
5+
image: mariadb:10.4
6+
environment:
7+
- MYSQL_ROOT_PASSWORD=mailtrain
8+
- MYSQL_DATABASE=mailtrain
9+
- MYSQL_USER=mailtrain
10+
- MYSQL_PASSWORD=mailtrain
11+
volumes:
12+
- mysql-data:/var/lib/mysql
13+
14+
redis:
15+
image: redis:5
16+
volumes:
17+
- redis-data:/data
18+
19+
mongo:
20+
image: mongo:4-xenial
21+
volumes:
22+
- mongo-data:/data/db
23+
24+
mailtrain:
25+
build: .
26+
command: ${MAILTRAIN_SETTINGS}
27+
ports:
28+
- "3000:3000"
29+
- "3003:3003"
30+
- "3004:3004"
31+
volumes:
32+
- mailtrain-files:/app/server/files
33+
- mailtrain-reports:/app/protected/reports
34+
35+
volumes:
36+
mysql-data:
37+
redis-data:
38+
mongo-data:
39+
mailtrain-files:
40+
mailtrain-reports:
41+

docker-entrypoint.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
set -e
3+
4+
function printHelp {
5+
cat <<EOF
6+
7+
Optional parameters:
8+
--trustedUrlBase XXX - sets the trusted url of the instance (default: http://localhost:3000)
9+
--sandboxUrlBase XXX - sets the sandbox url of the instance (default: http://localhost:3003)
10+
--publicUrlBase XXX - sets the public url of the instance (default: http://localhost:3004)
11+
--withProxy - use if Mailtrain is behind an http reverse proxy
12+
EOF
13+
14+
exit 1
15+
}
16+
17+
18+
urlBaseTrusted=http://localhost:3000
19+
urlBaseSandbox=http://localhost:3003
20+
urlBasePublic=http://localhost:3004
21+
wwwProxy=false
22+
23+
while [ $# -gt 0 ]; do
24+
case "$1" in
25+
--help)
26+
printHelp
27+
;;
28+
--trustedUrlBase)
29+
urlBaseTrusted="$2"
30+
shift 2
31+
;;
32+
--sandboxUrlBase)
33+
urlBaseSandbox="$2"
34+
shift 2
35+
;;
36+
--publicUrlBase)
37+
urlBasePublic="$2"
38+
shift 2
39+
;;
40+
--withProxy)
41+
wwwProxy=true
42+
shift 1
43+
;;
44+
*)
45+
echo "Error: unrecognized option $1."
46+
printHelp
47+
esac
48+
done
49+
50+
51+
cat > server/config/production.yaml <<EOT
52+
www:
53+
host: 0.0.0.0
54+
proxy: $wwwProxy
55+
secret: "`pwgen -1`"
56+
trustedUrlBase: $urlBaseTrusted
57+
sandboxUrlBase: $urlBaseSandbox
58+
publicUrlBase: $urlBasePublic
59+
60+
mysql:
61+
host: mysql
62+
63+
redis:
64+
enabled: true
65+
host: redis
66+
67+
log:
68+
level: info
69+
70+
builtinZoneMTA:
71+
log:
72+
level: warn
73+
mongo: mongodb://mongo:27017/zone-mta
74+
redis: redis://redis:6379/2
75+
76+
queue:
77+
processes: 5
78+
EOT
79+
80+
cat >> server/services/workers/reports/config/production.yaml <<EOT
81+
log:
82+
level: warn
83+
EOT
84+
85+
# Wait for the other services to start
86+
while ! nc -z mysql 3306; do sleep 1; done
87+
while ! nc -z redis 6379; do sleep 1; done
88+
while ! nc -z mongo 27017; do sleep 1; done
89+
90+
cd server
91+
NODE_ENV=production node index.js

docker/docker-compose.override.yml.tmpl

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker/docker-compose.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

docker/docker-entrypoint.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

server/config/docker-production.toml.tmpl

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)