Merge pull request #255 from tiangolo/feature/docker-nodejs
Docker updates
This commit is contained in:
commit
020b29ce9c
8 changed files with 101 additions and 73 deletions
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -27,3 +27,7 @@ public/grapejs/uploads/*
|
||||||
public/grapejs/templates/*
|
public/grapejs/templates/*
|
||||||
!public/grapejs/templates/demo
|
!public/grapejs/templates/demo
|
||||||
!public/grapejs/templates/aves
|
!public/grapejs/templates/aves
|
||||||
|
|
||||||
|
config/production.toml
|
||||||
|
workers/reports/config/production.toml
|
||||||
|
docker-compose.override.yml
|
14
Dockerfile
14
Dockerfile
|
@ -1,9 +1,13 @@
|
||||||
FROM centos
|
FROM node:8.1
|
||||||
RUN curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
|
|
||||||
RUN yum install -y git make gcc nodejs ImageMagick && yum clean all
|
# First install dependencies
|
||||||
COPY . /app
|
COPY ./package.json ./app/
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
RUN npm install --no-progress --production && npm install --no-progress passport-ldapjs
|
RUN npm install --no-progress --production && npm install --no-progress passport-ldapjs
|
||||||
|
# Later, copy the app files. That improves development speed as buiding the Docker image will not have
|
||||||
|
# to download and install all the NPM dependencies every time there's a change in the source code
|
||||||
|
COPY . /app
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["/usr/bin/node", "index.js"]
|
ENTRYPOINT ["bash", "/app/docker-entrypoint.sh"]
|
||||||
|
CMD ["node", "index.js"]
|
83
README.md
83
README.md
|
@ -120,78 +120,25 @@ If you are using the bundled ZoneMTA then you should make sure you are using a p
|
||||||
With proper SPF, DKIM and PTR records (DMARC wouldn't hurt either) I got perfect 10/10 score out from [MailTester](https://www.mail-tester.com/) when sending a campaign message to a MailTester test address. I did not have VERP turned on, so the sender address matched return path address.
|
With proper SPF, DKIM and PTR records (DMARC wouldn't hurt either) I got perfect 10/10 score out from [MailTester](https://www.mail-tester.com/) when sending a campaign message to a MailTester test address. I did not have VERP turned on, so the sender address matched return path address.
|
||||||
|
|
||||||
### Simple Install (Docker)
|
### Simple Install (Docker)
|
||||||
##### Requirements:
|
#### Requirements:
|
||||||
* Docker
|
|
||||||
* docker-compose
|
|
||||||
|
|
||||||
1. 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`
|
* [Docker](https://www.docker.com/)
|
||||||
2. Run `sudo docker build -t mailtrain-node:latest .`
|
* [Docker Compose](https://docs.docker.com/compose/)
|
||||||
3. Copy default.toml to production.toml. Run `sudo mkdir -p /etc/mailtrain && sudo cp config/default.toml /etc/mailtrain/production.toml`
|
|
||||||
4. Create `/etc/docker-compose.yml`. Example (dont forget change MYSQL_ROOT_PASS and MYSQL_USER_PASSWORD to your passwords):
|
|
||||||
```
|
|
||||||
version: '2'
|
|
||||||
services:
|
|
||||||
mailtrain-mysql:
|
|
||||||
image: mysql:latest
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
container_name: "mailtrain-mysql"
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: "MYSQL_ROOT_PASS"
|
|
||||||
MYSQL_DATABASE: "mailtrain"
|
|
||||||
MYSQL_USER: "mailtrain"
|
|
||||||
MYSQL_PASSWORD: "MYSQL_USER_PASSWORD"
|
|
||||||
volumes:
|
|
||||||
- mailtrain-mysq-data:/var/lib/mysql
|
|
||||||
|
|
||||||
mailtrain-redis:
|
#### Install:
|
||||||
image: redis:3.0
|
|
||||||
container_name: "mailtrain-redis"
|
|
||||||
volumes:
|
|
||||||
- mailtrain-redis-data:/data
|
|
||||||
|
|
||||||
mailtrain-node:
|
* 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`
|
||||||
image: mailtrain-node:latest
|
* **Note**: depending on how you have configured your system and Docker you may need to prepend the commands below with `sudo`.
|
||||||
container_name: "mailtrain-node"
|
* Copy the file `docker-compose.override.yml.tmpl` to `docker-compose.override.yml.tmpl` and modify it if you need to.
|
||||||
links:
|
* Bring up the stack with: `docker-compose up -d`, by default it will use the included `docker-compose.yml` file and override some configurations taken from the `docker-compose.override.yml` file.
|
||||||
- "mailtrain-mysql:mailtrain-mysql"
|
* If you want to use only / copy the `docker-compose.yml` file (for example, if you were deploying with Rancher), you may need to first run `docker-compose build` to make sure your system has a Docker image `mailtrain:latest`.
|
||||||
- "mailtrain-redis:mailtrain-redis"
|
* Open [http://localhost:3000/](http://localhost:3000/) (change the host name `localhost` to the name of the host where you are deploying the system).
|
||||||
ports:
|
* Authenticate as user `admin` with password `test`
|
||||||
- "3000:3000"
|
* Navigate to [http://localhost:3000/settings](http://localhost:3000/settings) and update service configuration.
|
||||||
volumes:
|
* Navigate to [http://localhost:3000/users/account](http://localhost:3000/users/account) and update user information and password.
|
||||||
- "/etc/mailtrain/production.toml:/app/config/production.toml"
|
|
||||||
- "mailtrain-node-data:/app/public/grapejs/uploads"
|
|
||||||
- "mailtrain-node-data:/app/public/mosaico/uploads"
|
|
||||||
volumes:
|
|
||||||
mailtrain-mysq-data: {}
|
|
||||||
mailtrain-redis-data: {}
|
|
||||||
mailtrain-node-data: {}
|
|
||||||
|
|
||||||
```
|
|
||||||
5. Update MySQL and Redis credintial in `/etc/mailtrain/production.toml` like this:
|
|
||||||
```
|
|
||||||
[mysql]
|
|
||||||
host="mailtrain-mysql"
|
|
||||||
user="mailtrain"
|
|
||||||
password="MYSQL_USER_PASSWORD"
|
|
||||||
database="mailtrain"
|
|
||||||
port=3306
|
|
||||||
charset="utf8mb4"
|
|
||||||
timezone="UTC"
|
|
||||||
|
|
||||||
[redis]
|
|
||||||
enabled=true
|
|
||||||
host="mailtrain-redis"
|
|
||||||
port=6379
|
|
||||||
db=5
|
|
||||||
```
|
|
||||||
6. Run docker container with command `sudo docker-compose -f /etc/docker-compose.yml up -d`
|
|
||||||
7. Open [http://localhost:3000/](http://localhost:3000/)
|
|
||||||
8. Authenticate as `admin`:`test`
|
|
||||||
9. Navigate to [http://localhost:3000/settings](http://localhost:3000/settings) and update service configuration
|
|
||||||
10. Navigate to [http://localhost:3000/users/account](http://localhost:3000/users/account) and update user information and password
|
|
||||||
|
|
||||||
|
**Note**: If you need to add or modify custom configurations, copy the file `config/docker-production.toml.tmpl` to `config/production.toml` and modify as you need. By default, the Docker image will do just that, automatically, so you can bring up the stack and it will work with default configurations.
|
||||||
|
|
||||||
|
|
||||||
### Manual Install (any OS that supports Node.js)
|
### Manual Install (any OS that supports Node.js)
|
||||||
|
|
||||||
|
|
9
config/docker-production.toml.tmpl
Normal file
9
config/docker-production.toml.tmpl
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[mysql]
|
||||||
|
host="mysql"
|
||||||
|
|
||||||
|
[redis]
|
||||||
|
enabled=true
|
||||||
|
host="redis"
|
||||||
|
|
||||||
|
[reports]
|
||||||
|
enabled=true
|
14
docker-compose.override.yml.tmpl
Normal file
14
docker-compose.override.yml.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
restart: always
|
||||||
|
redis:
|
||||||
|
restart: always
|
||||||
|
mailtrain:
|
||||||
|
build: ./
|
||||||
|
# volumes:
|
||||||
|
# - ./:/app
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
restart: always
|
||||||
|
|
31
docker-compose.yml
Normal file
31
docker-compose.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=mailtrain
|
||||||
|
- MYSQL_DATABASE=mailtrain
|
||||||
|
- MYSQL_USER=mailtrain
|
||||||
|
- MYSQL_PASSWORD=mailtrain
|
||||||
|
volumes:
|
||||||
|
- mailtrain-mysq-data:/var/lib/mysql
|
||||||
|
redis:
|
||||||
|
image: redis:3.0
|
||||||
|
volumes:
|
||||||
|
- mailtrain-redis-data:/data
|
||||||
|
mailtrain:
|
||||||
|
image: mailtrain:latest
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- redis
|
||||||
|
volumes:
|
||||||
|
- mailtrain-node-config:/app/config
|
||||||
|
- mailtrain-node-data:/app/public/grapejs/uploads
|
||||||
|
- mailtrain-node-data:/app/public/mosaico/uploads
|
||||||
|
- mailtrain-node-reports:/app/protected/reports
|
||||||
|
volumes:
|
||||||
|
mailtrain-mysq-data: {}
|
||||||
|
mailtrain-redis-data: {}
|
||||||
|
mailtrain-node-data: {}
|
||||||
|
mailtrain-node-config: {}
|
||||||
|
mailtrain-node-reports: {}
|
18
docker-entrypoint.sh
Normal file
18
docker-entrypoint.sh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ ! -f "/app/config/production.toml" ] ; then
|
||||||
|
echo "No production.toml, copying from docker-production.toml.tmpl"
|
||||||
|
cp /app/config/docker-production.toml.tmpl /app/config/production.toml
|
||||||
|
fi
|
||||||
|
if [ ! -f "/app/workers/reports/config/production.toml" ] ; then
|
||||||
|
echo "No production.toml for reports"
|
||||||
|
if [ -f "/app/config/production.toml" ] ; then
|
||||||
|
echo "copying config/production.toml to reports config directory"
|
||||||
|
cp /app/config/production.toml /app/workers/reports/config/production.toml
|
||||||
|
else
|
||||||
|
echo "copying config/docker-production.toml.tmpl to reports config directory as production.toml"
|
||||||
|
cp /app/config/docker-production.toml.tmpl /app/workers/reports/config/production.toml
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
exec "$@"
|
Loading…
Reference in a new issue