1
0
mirror of https://github.com/zokradonh/kopano-docker.git synced 2026-08-11 16:32:59 +00:00

Refactor directory base to core

This commit is contained in:
Andre Zoledziowski
2018-06-25 11:05:45 +02:00
parent bfbb4cbe40
commit 9d81ea0045
11 changed files with 0 additions and 0 deletions
-66
View File
@@ -1,66 +0,0 @@
FROM debian:stretch
LABEL maintainer=az@zok.xyz \
version="2.0"
RUN mkdir -p /kopano/repo /kopano/data
WORKDIR /kopano/repo
ENV DEBIAN_FRONTEND noninteractive
# install basics
RUN apt-get update && \
apt-get install --no-install-recommends -y \
curl \
gpg \
ca-certificates \
moreutils \
locales \
apt-transport-https \
python3 && \
rm -rf /var/cache/apt /var/lib/apt/lists
RUN curl -s -S -L -o /usr/local/bin/confix https://raw.githubusercontent.com/budhash/confix/master/confix && \
chmod +x /usr/local/bin/confix && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
curl -s -S -L -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 && \
chmod a+x /usr/local/bin/dumb-init
# If you have active Kopano subscription you can change KOPANO_CORE_REPOSITORY_URL to
# https://serial:<YOURSERIAL>@download.kopano.io/supported/core:/final/Debian_9.0
# and replace <YOURSERIAL> with your serial. You can also use pre-final or any other repository branch.
# If you want to use community version please use images from hub.docker.com
ARG KOPANO_CORE_VERSION=newest
ARG KOPANO_REPOSITORY_BRANCH=master
ARG KOPANO_CORE_REPOSITORY_URL="http://buildproxy/supported/core:/${KOPANO_REPOSITORY_BRANCH}/Debian_9.0"
ARG KOPANO_REPOSITORY_FLAGS="trusted=yes"
# install kopano components
RUN set -x && \
echo ${KOPANO_CORE_VERSION} > /kopano/buildversion && \
echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano-core.list && \
curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add - && \
apt-get update && \
apt-get install --no-install-recommends -y \
kopano-server-packages="${KOPANO_CORE_VERSION}" \
php7.0-cli && \
rm -rf /var/cache/apt /var/lib/apt/lists && \
cp /usr/share/doc/kopano/example-config/*.cfg /etc/kopano/ && \
cp /usr/share/doc/kopano/example-config/*.cfg.gz /etc/kopano/ && \
gzip -d -f /etc/kopano/*.gz
ENV KOPANO_LOCALE="de_DE.UTF-8"
ENV KOPANO_USERSCRIPT_LOCALE="de_DE.UTF-8"
ENV LANG=en_US.UTF-8
ENV SERVICE_TO_START=server
COPY kcconf.py defaultconfigs/ start-service.sh /kopano/
RUN chmod a+x /kopano/start-service.sh
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD [ "/kopano/start-service.sh" ]
-23
View File
@@ -1,23 +0,0 @@
E-Mail attachment directory is by default in `/kopano/data/attachments/` so bind `/kopano/data` as volume.
You can reconfigure by setting environment variable `KCCONF_SERVER_ATTACHMENT_PATH`.
You can change all server.cfg settings you like prefixed with "`KCCONF_SERVER_`"
So specify "`KCCONF_SERVER_MYSQL_HOST`" for "mysql\_host" setting in "server.cfg".
Or specify "`KCCONF_LDAP_LDAP_SEARCH_BASE`" to set "ldap\_search_base" in "ldap.cfg".
This image activates ActiveDirectory mode (Not OpenLDAP).
So you need an ActiveDirectory already running to use this.
You may try to override default settings with "`KCCONF_*`" options but using OpenLDAP instead of ActiveDirectory will fail due to !include command in ldap.cfg. This docker image does not support any method to edit this file. Create your own Dockerfile to enable OpenLDAP.
For coredumps on crashes kopano-server requires the fs.suid_dumpable sysctl to contain the value 2, not 0.
The docker image kopano_ssl will create certificates for all containers. Those certificates are selfsigned and only for internal Kopano component communication.
kopano_webapp port 80 is meant to be published through a https reverse proxy. MAPI connection for Outlook is also handled over port 80.
Maybe you need to execute `kopano-cli --list-users` once after initial install in the kopano_server container
see https://documentation.kopano.io/kopanocore_administrator_manual/configure_kc_components.html#testing-ldap-configuration
Example:
`docker-compose exec kserver kopano-cli --list-users` (This may last very long without any console output.)
-15
View File
@@ -1,15 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/dagent.cfg":
{
'log_file': "-",
'log_level': "4",
'tmp_path': "/tmp/dagent/"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-18
View File
@@ -1,18 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/gateway.cfg":
{
'log_file': "-",
'log_level': "4",
'tmp_path': "/tmp/gateway/",
'pop3_enable': "no",
'imap_enable': "no",
'imaps_enable': "yes"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-14
View File
@@ -1,14 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/ical.cfg":
{
'log_file': "-",
'log_level': "4"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-14
View File
@@ -1,14 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/monitor.cfg":
{
'log_file': "-",
'log_level': "4"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-14
View File
@@ -1,14 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/search.cfg":
{
'log_file': "-",
'log_level': "4"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-23
View File
@@ -1,23 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/server.cfg":
{
'log_file': "-",
'log_level': "3",
'attachment_path': "/kopano/data/attachments/",
'user_plugin': "ldap",
'server_listen': "",
'server_listen_tls': "*:237"
},
r"/etc/kopano/ldap.cfg":
{
'kccomment': ["!include /usr/share/kopano/ldap.openldap.cfg"],
'kcuncomment': ["!include /usr/share/kopano/ldap.active-directory.cfg"]
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-15
View File
@@ -1,15 +0,0 @@
import os
import kcconf
# Component specific configurations
kcconf.configkopano({
r"/etc/kopano/spooler.cfg":
{
'log_file': "-",
'log_level': "4",
'tmp_path': "/tmp/spooler/"
}
})
# Override configs from environment variables
kcconf.configkopano(kcconf.parseenvironmentvariables(r"/etc/kopano/"))
-57
View File
@@ -1,57 +0,0 @@
"""This module provides functions for easy editing of kopano config files \
via environment variables"""
import re
import os
import os.path
def configkopano(configs):
for filename, config in configs.items():
if not os.path.exists(filename):
return
with open(filename) as f:
contents = f.read()
f.close()
for key, newvalue in config.items():
if key == "kccomment":
for line in newvalue:
contents = re.sub(r"^\s*" + re.escape(line), r"#{}".format(line), contents, 0, re.MULTILINE)
elif key == "kcuncomment":
for line in newvalue:
contents = re.sub(r"^\s*#\s*" + re.escape(line) , line, contents, 0, re.MULTILINE)
else:
contents = re.sub(r"^\s*#?\s*{}\s*=.*".format(key), r"{} = {}".format(key, newvalue), contents, 0, re.MULTILINE)
with open(filename, "w") as f:
f.write(contents)
f.close()
def parseenvironmentvariables(prependingpath):
configs = dict()
for name, value in os.environ.items():
namematch = re.match(r"^KCCONF_([A-Z]+)_([A-Z0-9_]+)$", name)
if namematch != None:
filename = namematch.group(1).lower() + ".cfg"
if prependingpath + filename not in configs:
configs[prependingpath + filename] = dict()
confkey = namematch.group(2).lower()
configs[prependingpath + filename][confkey] = value
commentmatch = re.match(r"^KCCOMMENT_([A-Z]+)_([A-Z0-9_]+)$", name)
if commentmatch != None:
filename = commentmatch.group(1).lower() + ".cfg"
try:
configs[prependingpath + filename]["kccomment"].append(value)
except IndexError:
configs[prependingpath + filename]["kccomment"] = []
configs[prependingpath + filename]["kccomment"].append(value)
uncommentmatch = re.match(r"^KCUNCOMMENT_([A-Z]+)_([A-Z0-9_]+)$", name)
if uncommentmatch != None:
filename = uncommentmatch.group(1).lower() + ".cfg"
try:
configs[prependingpath + filename]["kunccomment"].append(value)
except IndexError:
configs[prependingpath + filename]["kunccomment"] = []
configs[prependingpath + filename]["kunccomment"].append(value)
return configs
-47
View File
@@ -1,47 +0,0 @@
#!/bin/bash
set -eu # unset variables are errors & non-zero return values exit the whole script
if [ ! -e /kopano/$SERVICE_TO_START.py ]
then
echo "Invalid service specified: $SERVICE_TO_START" | ts
exit 1
fi
mkdir -p /kopano/data/attachments /tmp/$SERVICE_TO_START /var/run/kopano
echo "Configure core service '$SERVICE_TO_START'" | ts
/usr/bin/python3 /kopano/$SERVICE_TO_START.py
echo "Set config ownership" | ts
chown -R kopano:kopano /kopano/data /run /tmp
echo "Clean old pid files and sockets" | ts
rm -f /var/run/kopano/*
case "$SERVICE_TO_START" in
server)
exec /usr/sbin/kopano-server -F
;;
dagent)
exec /usr/sbin/kopano-dagent -l
;;
gateway)
exec /usr/sbin/kopano-gateway -F
;;
ical)
exec /usr/sbin/kopano-ical -F
;;
monitor)
exec /usr/sbin/kopano-monitor -F
;;
search)
exec /usr/bin/python /usr/sbin/kopano-search -F
;;
spooler)
exec /usr/sbin/kopano-spooler -F
;;
*)
echo "Failed to start: Unknown service name: '$SERVICE_TO_START'" | ts
exit 1
esac