diff --git a/core/Dockerfile b/core/Dockerfile index f935a08..f42bf2b 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer=az@zok.xyz \ RUN mkdir -p /kopano/repo /kopano/data WORKDIR /kopano/repo -ENV DEBIAN_FRONTEND noninteractive +ARG DEBIAN_FRONTEND=noninteractive # install basics RUN apt-get update && \ @@ -17,34 +17,39 @@ RUN apt-get update && \ moreutils \ locales \ apt-transport-https \ + apt-utils jq \ python3-minimal && \ 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 && \ +RUN 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:@download.kopano.io/supported/core:/final/Debian_9.0 -# and replace 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_CORE_REPOSITORY_URL="file:/kopano/repo" ARG KOPANO_REPOSITORY_FLAGS="trusted=yes" -ARG NO_RELEASE_KEY_DOWNLOAD=0 +ARG DOWNLOAD_COMMUNITY_PACKAGES=1 +ARG RELEASE_KEY_DOWNLOAD=0 ARG ADDITIONAL_KOPANO_PACKAGES -# install kopano components -RUN set -x && \ +# community build +COPY download_community.sh /kopano/download_community.sh + +RUN \ + # community download + [ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ] && \ + chmod a+x /kopano/download_community.sh && \ + /kopano/download_community.sh core && \ + gzip -f9 Packages; \ + # install + 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; \ - (exit ${NO_RELEASE_KEY_DOWNLOAD}) && curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add -; \ + [ ${RELEASE_KEY_DOWNLOAD} -eq 1 ] && 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}" \ diff --git a/core/README.md b/core/README.md index 52a90ee..449d618 100644 --- a/core/README.md +++ b/core/README.md @@ -15,8 +15,22 @@ The docker image kopano_ssl will create certificates for all containers. Those c 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 +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.) \ No newline at end of file + +`docker-compose exec kserver kopano-cli --list-users` (This may last very long without any console output.) + + +Building supported Kopano +===== +If you have an active Kopano subscription you need specify the following build time arguments: +- KOPANO_CORE_REPOSITORY_URL to `https://serial:@download.kopano.io/supported/core:/final/Debian_9.0` +- RELEASE_KEY_DOWNLOAD to 1 +- DOWNLOAD_COMMUNITY_PACKAGES to 0 + +Example: + +`docker build --build-arg KOPANO_CORE_REPOSITORY_URL=https://serial:ABC123456789@download.kopano.io/supported/core:/final/Debian_9.0 --build-arg RELEASE_KEY_DOWNLOAD=1 --build-arg DOWNLOAD_COMMUNITY_PACKAGES=0 https://github.com/zokradonh/kopano-docker.git#:core` \ No newline at end of file diff --git a/core/download_community.sh b/core/download_community.sh new file mode 100644 index 0000000..a8cc17e --- /dev/null +++ b/core/download_community.sh @@ -0,0 +1,23 @@ +#!/bin/bash + + +function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } + +# query community server by h5ai API +filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$1%3A%2F&items%5Bwhat%5D=1" -H \ + "Accept: application/json" https://download.kopano.io/community/ | jq '.items[].href' | \ + grep Debian_9.0-amd64 | sed 's#"##g' | sed "s#/community/$1:/##") + +filename=$(urldecode $filename) + +# download & extract packages +curl -s -S -L -o $filename https://download.kopano.io/community/$1:/${filename} + +tar xf $filename + +# save disk space +rm $filename + +# prepare directory to be apt source +apt-ftparchive packages ${filename%.tar.gz} >> Packages + diff --git a/core/start-service.sh b/core/start-service.sh index 02a8ebe..f3d0c2f 100644 --- a/core/start-service.sh +++ b/core/start-service.sh @@ -13,8 +13,9 @@ 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 "Set ownership" | ts +chown -R kopano:kopano /run /tmp +chown kopano:kopano /kopano/data/ /kopano/data/attachments echo "Clean old pid files and sockets" | ts rm -f /var/run/kopano/*