diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da975d..c3820c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 1.1.8 - [docker](Dockerfile) Configure z-push to use HTTP_X_FORWARDED_FOR. +- [demo](demo) Made service names shorter. # 1.1.7 diff --git a/README.md b/README.md index 37503aa..046e6b2 100644 --- a/README.md +++ b/README.md @@ -40,26 +40,26 @@ To exemplify the usage of the tags, lets assume that the latest version tag is ` In most use cases the `mlan/kopano` container also needs a SQL database (e.g., [MySQL](https://hub.docker.com/_/mysql) or [MariaDB](https://hub.docker.com/_/mariadb)), Mail Transfer Agent (e.g., [Postfix](http://www.postfix.org/)) and authentication (e.g., [OpenLDAP](https://www.openldap.org/)). Docker images of such services are available. -Often you want to configure Kopano and its components. There are +Often you want to configure Kopano and its components. There are different methods available to achieve this. You can use the environment -variables described below set in the shell before creating the container. -These environment variables can also be explicitly given on -the command line when creating the container. They can also be given in -an `docker-compose.yml` file (and the `.env` file), see below. Moreover docker -volumes or host directories with desired configuration files can be +variables described below set in the shell before creating the container. +These environment variables can also be explicitly given on +the command line when creating the container. They can also be given in +an `docker-compose.yml` file (and the `.env` file), see below. Moreover docker +volumes or host directories with desired configuration files can be mounted in the container. And finally you can exec into a running container and modify configuration files directly. The docker compose example below is used to demonstrate how to configure these services. ## Docker compose example -An example of how to configure an web mail server using [docker compose](https://docs.docker.com/compose) is given below. It defines 4 services, `mail-app`, `mail-mta`, `mail-db` and `auth`, which are the web mail server, the mail transfer agent, the SQL database and LDAP authentication respectively. +An example of how to configure an web mail server using docker compose is given below. It defines 4 services, `app`, `mta`, `db` and `auth`, which are the web mail server, the mail transfer agent, the SQL database and LDAP authentication respectively. ```yaml version: '3' services: - mail-app: + app: image: mlan/kopano networks: - backend @@ -67,13 +67,13 @@ services: - "127.0.0.1:8080:80" depends_on: - auth - - mail-db - - mail-mta + - db + - mta environment: - USER_PLUGIN=ldap - LDAP_URI=ldap://auth:389/ - - MYSQL_HOST=mail-db - - SMTP_SERVER=mail-mta + - MYSQL_HOST=db + - SMTP_SERVER=mta - LDAP_SEARCH_BASE=${LDAP_BASE-dc=example,dc=com} - LDAP_USER_TYPE_ATTRIBUTE_VALUE=${LDAP_USEROBJ-posixAccount} - LDAP_GROUP_TYPE_ATTRIBUTE_VALUE=${LDAP_GROUPOBJ-posixGroup} @@ -82,13 +82,13 @@ services: - MYSQL_PASSWORD=${MYSQL_PASSWORD-secret} - SYSLOG_LEVEL=${SYSLOG_LEVEL-3} volumes: - - mail-conf:/etc/kopano - - mail-atch:/var/lib/kopano/attachments - - mail-sync:/var/lib/z-push - - mail-spam:/var/lib/kopano/spamd # kopano-spamd integration + - app-conf:/etc/kopano + - app-atch:/var/lib/kopano/attachments + - app-sync:/var/lib/z-push + - app-spam:/var/lib/kopano/spamd # kopano-spamd integration - /etc/localtime:/etc/localtime:ro # Use host timezone - mail-mta: + mta: image: mlan/postfix-amavis hostname: ${MAIL_SRV-mx}.${MAIL_DOMAIN-example.com} networks: @@ -99,15 +99,15 @@ services: - auth environment: - LDAP_HOST=auth - - VIRTUAL_TRANSPORT=lmtp:mail-app:2003 + - VIRTUAL_TRANSPORT=lmtp:app:2003 - LDAP_USER_BASE=ou=${LDAP_USEROU-users},${LDAP_BASE-dc=example,dc=com} - LDAP_QUERY_FILTER_USER=(&(objectclass=${LDAP_USEROBJ-posixAccount})(mail=%s)) volumes: - - mail-mta:/srv - - mail-spam:/var/lib/kopano/spamd # kopano-spamd integration + - mta:/srv + - app-spam:/var/lib/kopano/spamd # kopano-spamd integration - /etc/localtime:/etc/localtime:ro # Use host timezone - mail-db: + db: image: mariadb command: ['--log_warnings=1'] networks: @@ -119,7 +119,7 @@ services: - MYSQL_USER=${MYSQL_USER-kopano} - MYSQL_PASSWORD=${MYSQL_PASSWORD-secret} volumes: - - mail-db:/var/lib/mysql + - db:/var/lib/mysql - /etc/localtime:/etc/localtime:ro # Use host timezone auth: @@ -129,20 +129,20 @@ services: environment: - LDAP_LOGLEVEL=parse volumes: - - auth-db:/srv + - auth:/srv - /etc/localtime:/etc/localtime:ro # Use host timezone networks: backend: volumes: - auth-db: - mail-conf: - mail-atch: - mail-db: - mail-mta: - mail-spam: - mail-sync: + app-atch: + app-conf: + app-spam: + app-sync: + auth: + db: + mta: ``` This repository contains a [demo](demo) directory which hold the [docker-compose.yml](demo/docker-compose.yml) file as well as a [Makefile](demo/Makefile) which might come handy. From within the [demo](demo) directory you can start the containers by typing: @@ -156,6 +156,11 @@ Then you can assess WebApp on the URL [`http://localhost:8080`](http://localhost ```bash make test ``` +When you are done testing you can destroy the test container by typing: + +```bash +make destroy +``` ## Environment variables diff --git a/demo/Makefile b/demo/Makefile index d978e47..21eb5c7 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -1,5 +1,6 @@ -include *.mk .env .init.env +srv_list ?= auth app db mta _ip = $(shell docker inspect -f \ '{{range .NetworkSettings.Networks}}{{println .IPAddress}}{{end}}' \ $(1) | head -n1) @@ -9,11 +10,13 @@ _ip = $(shell docker inspect -f \ variables: make -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq +test: mta-test + +init: auth-up wait_11 auth-mod_index auth-add_user db-up mta-up app-up + ps: docker-compose ps -init: auth-up wait_11 auth-mod_index auth-add_user mail-db-up mail-mta-up mail-app-up - up: docker-compose up -d @@ -29,26 +32,43 @@ config: logs: docker-compose logs --tail 10 +images: + docker-compose images + +$(addsuffix -up,$(srv_list)): + docker-compose up -d $(patsubst %-up,%,$@) + +$(addsuffix -down,$(srv_list)): + docker-compose rm -s $(patsubst %-down,%,$@) + +$(addsuffix -restart,$(srv_list)): + docker-compose restart $(patsubst %-restart,%,$@) + +$(addsuffix -renew,$(srv_list)): + docker-compose rm -s $(patsubst %-renew,%,$@) + docker-compose up -d $(patsubst %-renew,%,$@) + +$(addsuffix -top,$(srv_list)): + docker-compose top $(patsubst %-top,%,$@) + +$(addsuffix -logs,$(srv_list)): + docker-compose logs $(patsubst %-logs,%,$@) + +$(addsuffix -sh,$(srv_list)): + docker-compose exec $(patsubst %-sh,%,$@) sh + +$(addsuffix -sv,$(srv_list)): + docker-compose exec $(patsubst %-sv,%,$@) sh -c 'sv status $$DOCKER_RUNSV_DIR/*' + +$(addsuffix -diff,$(srv_list)): + docker container diff $(COMPOSE_PROJECT_NAME)_$(patsubst %-diff,%,$@)_1 + wait_%: sleep $* web: firefox localhost:8080 & -test: mail-mta-test - -auth-up: - docker-compose up -d auth - -auth-down: - docker-compose rm -s auth - -auth-cmd: - docker-compose exec auth /bin/sh - -auth-logs: - docker container logs $(COMPOSE_PROJECT_NAME)_auth_1 - auth-show_conf: docker-compose exec auth ldap search -b cn=config olcDatabase={1}mdb @@ -63,101 +83,65 @@ auth-mod_index: printf "dn: olcDatabase={1}mdb,cn=config\nchangetype: modify\nadd: olcDbIndex\nolcDbIndex: cn,ou,uid,mail eq\n" \ | docker-compose exec -T auth ldap modify -mail-mta-up: - docker-compose up -d mail-mta +mta-bayes: + docker-compose exec mta sh -c 'rm -f bayesian.database.gz && wget http://artinvoice.hu/spams/bayesian.database.gz && gunzip bayesian.database.gz && sa-learn --restore bayesian.database && chown -R amavis: /var/amavis/.spamassassin && rm -rf bayesian.database' -mail-mta-down: - docker-compose rm -s mail-mta - -mail-mta-cmd: - docker-compose exec mail-mta /bin/sh - -mail-mta-logs: - docker container logs $(COMPOSE_PROJECT_NAME)_mail-mta_1 - -mail-mta-diff: - docker container diff $(COMPOSE_PROJECT_NAME)_mail-mta_1 - -mail-mta-bayes: - docker-compose exec mail-mta sh -c 'rm -f bayesian.database.gz && wget http://artinvoice.hu/spams/bayesian.database.gz && gunzip bayesian.database.gz && sa-learn --restore bayesian.database && chown -R amavis: /var/amavis/.spamassassin && rm -rf bayesian.database' - -mail-mta-test: +mta-test: printf "EHLO mx\nMAIL FROM: \nRCPT TO: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDATA\nFrom: A tester \nTo: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTP test message\n\nGreat news! You can receive email.\n.\nQUIT\n" \ | nc -C localhost 25 -mail-mta-razor: - docker-compose exec mail-mta conf cntcfg_razor_register +mta-razor: + docker-compose exec mta conf cntcfg_razor_register -mail-mta-apk_list: - docker-compose exec mail-mta /bin/sh -c 'for pkg in $$(apk info 2>/dev/null); do printf "%9s %s\n" $$(apk info -s $$pkg 2>/dev/null | sed -n "2{p;q}") $$pkg; done | sort' +mta-apk_list: + docker-compose exec mta /bin/sh -c 'for pkg in $$(apk info 2>/dev/null); do printf "%9s %s\n" $$(apk info -s $$pkg 2>/dev/null | sed -n "2{p;q}") $$pkg; done | sort' -mail-mta-quarantine_list: - docker-compose exec mail-mta amavisd-ls +mta-quarantine_list: + docker-compose exec mta amavis-ls -mail-mta-freshclam_nodns: - docker-compose exec mail-mta freshclam --no-dns +mta-freshclam_nodns: + docker-compose exec mta freshclam --no-dns -mail-mta-debugtools: - docker-compose exec mail-mta apk --no-cache --update add \ +mta-clamdtop: + docker-compose exec mta clamdtop + +mta-debugtools: + docker-compose exec mta apk --no-cache --update add \ nano less lsof htop openldap-clients bind-tools iputils strace -mail-db-up: - docker-compose up -d mail-db +mta-htop: mta-debugtools + docker-compose exec mta htop -mail-db-down: - docker-compose rm -s mail-db +db-test: + docker-compose exec db mysqlshow -u $(MYSQL_USER) $(MYSQL_DATABASE) -p$(MYSQL_PASSWORD) -mail-db-cmd: - docker-compose exec mail-db /bin/bash - -mail-db-logs: - docker container logs $(COMPOSE_PROJECT_NAME)_mail-db_1 - -mail-db-diff: - docker container diff $(COMPOSE_PROJECT_NAME)_mail-db_1 - -mail-db-test: - docker-compose exec mail-db mysqlshow -u $(MYSQL_USER) $(MYSQL_DATABASE) -p$(MYSQL_PASSWORD) - -mail-app-up: - docker-compose up -d mail-app - -mail-app-down: - docker-compose rm -s mail-app - -mail-app-cmd: - docker-compose exec mail-app /bin/bash - -mail-app-logs: - docker container logs $(COMPOSE_PROJECT_NAME)_mail-app_1 - -mail-app-diff: - docker container diff $(COMPOSE_PROJECT_NAME)_mail-app_1 - -mail-app-debugtools: - docker-compose exec mail-app apt-get update - docker-compose exec mail-app apt-get install --yes \ +app-debugtools: + docker-compose exec app apt-get update + docker-compose exec app apt-get install --yes \ less nano ldap-utils htop net-tools lsof iputils-ping strace -mail-app-htop: mail-app-debugtools - docker-compose exec mail-app htop +app-htop: app-debugtools + docker-compose exec app htop -mail-app-man_server: - docker-compose exec mail-app man kopano-server.cfg +app-man_server: + docker-compose exec app man kopano-server.cfg -mail-app-man_ldap: - docker-compose exec mail-app man kopano-ldap.cfg +app-man_ldap: + docker-compose exec app man kopano-ldap.cfg -mail-app-test_smtp: mail-mta-test +app-test_smtp: mta-test -mail-app-test_lmtp: - printf "LHLO mx\nMAIL FROM: \nRCPT TO: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDATA\nFrom: A tester \nTo: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A LMTP test message from me to you\n\nDelete me, please \n.\nQUIT\n" | nc -C $(call _ip,$(COMPOSE_PROJECT_NAME)_mail-app_1) 2003 +app-test_lmtp: + printf "LHLO mx\nMAIL FROM: \nRCPT TO: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDATA\nFrom: A tester \nTo: <$(LDAP_TEST_USER)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A LMTP test message from me to you\n\nDelete me, please \n.\nQUIT\n" | nc -C $(call _ip,$(COMPOSE_PROJECT_NAME)_app_1) 2003 -mail-app-show_user1: - docker-compose exec mail-app kopano-admin -l +app-show_user1: + docker-compose exec app kopano-admin -l -mail-app-show_user2: mail-app-debugtools - docker-compose exec mail-app ldapsearch -H ldap://auth:389 -xLLL -b $(LDAP_BASE) '*' +app-show_user2: app-debugtools + docker-compose exec app ldapsearch -H ldap://auth:389 -xLLL -b $(LDAP_BASE) '*' -mail-app-create_store: - docker-compose exec mail-app kopano-admin --create-store $(LDAP_TEST_USER) +app-show_sync: + docker-compose exec app z-push-top + +app-create_store: + docker-compose exec app kopano-admin --create-store $(LDAP_TEST_USER) diff --git a/demo/docker-compose.yml b/demo/docker-compose.yml index 823d448..b295375 100644 --- a/demo/docker-compose.yml +++ b/demo/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: - mail-app: + app: image: mlan/kopano networks: - backend @@ -9,13 +9,13 @@ services: - "127.0.0.1:8080:80" depends_on: - auth - - mail-db - - mail-mta + - db + - mta environment: - USER_PLUGIN=ldap - LDAP_URI=ldap://auth:389/ - - MYSQL_HOST=mail-db - - SMTP_SERVER=mail-mta + - MYSQL_HOST=db + - SMTP_SERVER=mta - LDAP_SEARCH_BASE=${LDAP_BASE-dc=example,dc=com} - LDAP_USER_TYPE_ATTRIBUTE_VALUE=${LDAP_USEROBJ-posixAccount} - LDAP_GROUP_TYPE_ATTRIBUTE_VALUE=${LDAP_GROUPOBJ-posixGroup} @@ -24,15 +24,15 @@ services: - MYSQL_PASSWORD=${MYSQL_PASSWORD-secret} - SYSLOG_LEVEL=${SYSLOG_LEVEL-3} volumes: - - mail-conf:/etc/kopano - - mail-atch:/var/lib/kopano/attachments - - mail-sync:/var/lib/z-push - - mail-spam:/var/lib/kopano/spamd # kopano-spamd integration + - app-conf:/etc/kopano + - app-atch:/var/lib/kopano/attachments + - app-sync:/var/lib/z-push + - app-spam:/var/lib/kopano/spamd # kopano-spamd integration - /etc/localtime:/etc/localtime:ro # Use host timezone cap_add: # helps debugging by alowing strace - sys_ptrace - mail-mta: + mta: image: mlan/postfix-amavis hostname: ${MAIL_SRV-mx}.${MAIL_DOMAIN-example.com} networks: @@ -44,7 +44,7 @@ services: environment: - MESSAGE_SIZE_LIMIT=${MESSAGE_SIZE_LIMIT-25600000} - LDAP_HOST=auth - - VIRTUAL_TRANSPORT=lmtp:mail-app:2003 + - VIRTUAL_TRANSPORT=lmtp:app:2003 - SMTP_RELAY_HOSTAUTH=${SMTP_RELAY_HOSTAUTH-} - SMTP_TLS_SECURITY_LEVEL=${SMTP_TLS_SECURITY_LEVEL-} - SMTP_TLS_WRAPPERMODE=${SMTP_TLS_WRAPPERMODE-no} @@ -57,13 +57,13 @@ services: - LOG_LEVEL=${LOG_LEVEL-0} - RAZOR_REGISTRATION=${RAZOR_REGISTRATION-} volumes: - - mail-mta:/srv - - mail-spam:/var/lib/kopano/spamd # kopano-spamd integration + - mta:/srv + - app-spam:/var/lib/kopano/spamd # kopano-spamd integration - /etc/localtime:/etc/localtime:ro # Use host timezone cap_add: # helps debugging by alowing strace - sys_ptrace - mail-db: + db: image: mariadb command: ['--log_warnings=1'] networks: @@ -75,7 +75,7 @@ services: - MYSQL_USER=${MYSQL_USER-kopano} - MYSQL_PASSWORD=${MYSQL_PASSWORD-secret} volumes: - - mail-db:/var/lib/mysql + - db:/var/lib/mysql - /etc/localtime:/etc/localtime:ro # Use host timezone auth: @@ -85,17 +85,17 @@ services: environment: - LDAP_LOGLEVEL=parse volumes: - - auth-db:/srv + - auth:/srv - /etc/localtime:/etc/localtime:ro # Use host timezone networks: backend: volumes: - auth-db: - mail-conf: - mail-atch: - mail-db: - mail-mta: - mail-spam: - mail-sync: + app-atch: + app-conf: + app-spam: + app-sync: + auth: + db: + mta: