Adapt for Networ7 environment

- Add clamav

- Use nlss/mariadb

- Add healthchecks

- Overall improvements
This commit is contained in:
xZero707 2021-05-27 19:09:16 +02:00
parent e97b062207
commit b55e5e4577
4 changed files with 146 additions and 54 deletions

View File

@ -1,64 +1,146 @@
version: "3" version: "3"
services: services:
postal:
image: catdeployed/postal:alpine nginx:
container_name: postal image: nginx:mainline-alpine
command: run links:
ports: - service
- 127.0.0.1:25:25
depends_on: depends_on:
- "mysql" - service
- "rabbitmq"
volumes: volumes:
- persistent_assets:/storage - ./src/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- static_assets:/opt/postal/public:ro
- assets:/opt/postal/public/assets:ro
networks:
default: {aliases: [ postal_nginx, nginx ]}
http:
restart: unless-stopped
healthcheck:
test: [ "CMD", "curl", "--fail", "http://127.0.0.1" ]
interval: 15s
timeout: 10s
retries: 3
service:
image: catdeployed/postal:alpine
build:
context: .
command: run
depends_on:
- systemdb
- messagedb
- queue
- clamav
volumes:
- storage:/storage
- static_assets:/opt/postal/public - static_assets:/opt/postal/public
- postal_assets:/opt/postal/public/assets - assets:/opt/postal/public/assets
- ./src/templates/:/templates - ./src/templates/:/templates
environment: environment:
- MYSQL_ROOT_PASSWORD=changeme - CLAMAV_HOST=clamav
- MYSQL_DATABASE=postal - CLAMAV_PORT=3310
- SYSTEMDB_HOST=systemdb
- SYSTEMDB_DATABASE=postal
- SYSTEMDB_USER=root
- SYSTEMDB_PASSWORD=SQtDHUD7spitQQvoQ^2vSCTZBg5nX^
- MESSAGEDB_HOST=messagedb
- MESSAGEDB_DATABASE=messages
- MESSAGEDB_USER=root
- MESSAGEDB_PASSWORD=SQtDHUD7spitQQvoQ^2vSCTZBg5nX^
- RABBITMQ_DEFAULT_USER=postal - RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme - RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=postal - RABBITMQ_DEFAULT_VHOST=postal
- POSTAL_FNAME=Sia - POSTAL_FNAME=Sia
- POSTAL_LNAME=Cat - POSTAL_LNAME=Cat
- POSTAL_PASSWORD=SecretCatPassword - POSTAL_PASSWORD=hDzqLsP5hEXuBinpQ3KHSknvgTxRu6
- POSTAL_EMAIL=myemail@catsworld.com - POSTAL_EMAIL=aleksandar@puharic.com
networks:
default: { aliases: [ postal, service ] }
client: { aliases: [ postal, mailer, mailer-service ] }
healthcheck: healthcheck:
test: curl -sS http://127.0.0.1:5000 || exit 1 test: curl -sS http://127.0.0.1:5000 || exit 1
interval: 5s interval: 5s
timeout: 10s timeout: 10s
retries: 3 retries: 3
mysql: restart: unless-stopped
image: mariadb:10
container_name: postal_mysql systemdb:
image: nlss/mariadb
volumes: volumes:
- mysql_data:/var/lib/mysql - systemdb_data:/var/lib/mysql
- systemdb_backup:/var/lib/backup
- systemdb_log:/var/log/mysql
environment: environment:
- MYSQL_ROOT_PASSWORD=changeme - MARIADB_ROOT_PASSWORD=SQtDHUD7spitQQvoQ^2vSCTZBg5nX^
- MYSQL_DATABASE=postal - MARIADB_DATABASE=postal
rabbitmq: networks:
default: { aliases: [ postal_mysql, mysql, mariadb, database ] }
restart: unless-stopped
healthcheck:
test: [ "CMD", "/usr/bin/healthcheck" ]
interval: 30s
timeout: 20s
retries: 3
messagedb:
image: nlss/mariadb
volumes:
- messagedb_data:/var/lib/mysql
- messagedb_backup:/var/lib/backup
- messagedb_log:/var/log/mysql
environment:
- MARIADB_ROOT_PASSWORD=SQtDHUD7spitQQvoQ^2vSCTZBg5nX^
- MARIADB_DATABASE=messages
networks:
default: { aliases: [ postal_mysql, mysql, mariadb, database ] }
restart: unless-stopped
healthcheck:
test: [ "CMD", "/usr/bin/healthcheck" ]
interval: 30s
timeout: 20s
retries: 3
queue:
image: rabbitmq:3-alpine image: rabbitmq:3-alpine
container_name: postal_rabbitmq
environment: environment:
- RABBITMQ_DEFAULT_USER=postal - RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme - RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=/postal - RABBITMQ_DEFAULT_VHOST=/postal
nginx: networks:
image: nginx default: { aliases: [ postal_rabbitmq, rabbitmq, queue ] }
container_name: postal_nginx restart: unless-stopped
ports: healthcheck:
- 80:80 test: rabbitmq-diagnostics -q ping
links: interval: 30s
- postal timeout: 30s
depends_on: retries: 3
- postal
clamav:
image: mkodockx/docker-clamav:alpine
volumes: volumes:
- ./src/nginx.conf:/etc/nginx/conf.d/default.conf:ro - clamav_data:/var/lib/clamav
- static_assets:/opt/postal/public:ro networks:
- postal_assets:/opt/postal/public/assets:ro default: { aliases: [ clamav ] }
healthcheck:
test: [ "CMD", "./check.sh" ]
interval: 60s
retries: 3
start_period: 120s
restart: unless-stopped
networks:
default:
client:
http:
volumes: volumes:
static_assets: static_assets:
postal_assets: assets:
mysql_data: clamav_data:
persistent_assets: systemdb_data:
systemdb_backup:
systemdb_log:
messagedb_data:
messagedb_backup:
messagedb_log:
storage:

View File

@ -22,7 +22,7 @@ elif [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/posta
## Generate config and keys ## Generate config and keys
/opt/postal/bin/postal initialize-config /opt/postal/bin/postal initialize-config
/opt/postal/bin/postal initialize /opt/postal/bin/postal initialize
/create-user.sh #/create-user.sh
## Copy over config to persistent storage ## Copy over config to persistent storage
cp -p /opt/postal/config/postal.yml /storage/postal.yml cp -p /opt/postal/config/postal.yml /storage/postal.yml
rm /opt/postal/config/postal.yml rm /opt/postal/config/postal.yml

View File

@ -21,18 +21,18 @@ general:
main_db: main_db:
# Specify the connection details for your MySQL database # Specify the connection details for your MySQL database
host: mysql host: {{ SYSTEMDB_HOST }}
username: root username: {{ SYSTEMDB_USER }}
password: {{ MYSQL_ROOT_PASSWORD }} password: {{ SYSTEMDB_PASSWORD }}
database: {{ MYSQL_DATABASE }} database: {{ SYSTEMDB_DATABASE }}
message_db: message_db:
# Specify the connection details for your MySQL server that will be house the # Specify the connection details for your MySQL server that will be house the
# message databases for mail servers. # message databases for mail servers.
host: mysql host: {{ MESSAGEDB_HOST }}
username: root username: {{ MESSAGEDB_USER }}
password: {{ MYSQL_ROOT_PASSWORD }} password: {{ MESSAGEDB_PASSWORD }}
prefix: postal database: {{ MESSAGEDB_DATABASE }}
rabbitmq: rabbitmq:
# Specify the connection details for your RabbitMQ server. # Specify the connection details for your RabbitMQ server.
@ -64,3 +64,8 @@ smtp:
from_name: Postal from_name: Postal
from_address: postal@yourdomain.com from_address: postal@yourdomain.com
clamav:
enabled: true
host: {{ CLAMAV_HOST }}
port: {{ CLAMAV_PORT }}

View File

@ -16,18 +16,18 @@ general:
main_db: main_db:
# Specify the connection details for your MySQL database # Specify the connection details for your MySQL database
host: mysql host: {{ SYSTEMDB_HOST }}
username: root username: {{ SYSTEMDB_USER }}
password: {{ MYSQL_ROOT_PASSWORD }} password: {{ SYSTEMDB_PASSWORD }}
database: {{ MYSQL_DATABASE }} database: {{ SYSTEMDB_DATABASE }}
message_db: message_db:
# Specify the connection details for your MySQL server that will be house the # Specify the connection details for your MySQL server that will be house the
# message databases for mail servers. # message databases for mail servers.
host: mysql host: {{ MESSAGEDB_HOST }}
username: root username: {{ MESSAGEDB_USER }}
password: {{ MYSQL_ROOT_PASSWORD }} password: {{ MESSAGEDB_PASSWORD }}
prefix: postal database: {{ MESSAGEDB_DATABASE }}
rabbitmq: rabbitmq:
# Specify the connection details for your RabbitMQ server. # Specify the connection details for your RabbitMQ server.
@ -66,3 +66,8 @@ rails:
web_server: web_server:
bind_address: 0.0.0.0 bind_address: 0.0.0.0
clamav:
enabled: true
host: {{ CLAMAV_HOST }}
port: {{ CLAMAV_PORT }}