1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-06-09 17:06:31 +00:00

Created another image for shared scripts.

This commit is contained in:
Andre Zoledziowski 2018-10-13 14:30:28 +02:00
parent 954de3757e
commit 8ce7f2abdc
No known key found for this signature in database
GPG Key ID: 2A72044119624966
10 changed files with 134 additions and 157 deletions

View File

@ -9,7 +9,7 @@ serial=""
component=""
nocache=""
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
. ./common/common.sh
function _usage()
{
@ -23,7 +23,7 @@ function _usage()
echo "-a You can specify custom build args via e.g. -a ADDITIONAL_KOPANO_PACKAGES=kopano-migration-imap"
}
while getopts ":s:c:b:p:n:a:i" opt; do
while getopts ":s:c:b:p:a:i" opt; do
case $opt in
s)
serial=$OPTARG
@ -81,12 +81,9 @@ then
# start build of supported kopano
# get current version to brand and tag the image correctly
currentVersion=$(curl -s -S -L https://serial:$serial@download.kopano.io/supported/$component:/$branch/Debian_9.0/Packages.gz |\
currentVersion=$(curl -s -S -L "https://serial:$serial@download.kopano.io/supported/$component:/$branch/Debian_9.0/Packages.gz" |\
gzip -d | grep -A 8 "^Package: $mainpackage$" | awk '/Version/ { print $2 }')
currentVersionDocker=$(echo $currentVersion | sed 's/+/plus/')
# webapp also needs core repository
if [ "$component" == "webapp" ]
then
@ -94,49 +91,48 @@ then
fi
echo "Start building supported kopano $component image version ($currentVersion)..."
set -x
# build it
docker build --build-arg KOPANO_${component^^}_REPOSITORY_URL=https://serial:$serial@download.kopano.io/supported/$component:/$branch/Debian_9.0 \
if docker build \
--pull \
--build-arg "KOPANO_${component^^}_REPOSITORY_URL=https://serial:$serial@download.kopano.io/supported/$component:/$branch/Debian_9.0" \
--build-arg RELEASE_KEY_DOWNLOAD=1 \
--build-arg DOWNLOAD_COMMUNITY_PACKAGES=0 \
--build-arg KOPANO_${component^^}_VERSION=$currentVersion \
-t zokradonh/kopano_$component:$currentVersionDocker \
-t zokradonh/kopano_$component:latest-$branch \
--build-arg "DOWNLOAD_COMMUNITY_PACKAGES=0" \
--build-arg "KOPANO_${component^^}_VERSION=$currentVersion" \
-t "zokradonh/kopano_$component:${currentVersion//+/plus}" \
-t "zokradonh/kopano_$component:latest-$branch" \
$nocache \
$customBuildString \
${buildcontext_base}${component}
if [ $? -eq 0 ]
"${buildcontext_base}${component}"
then
set +x
echo "Please note that this image does include your serial. If you publish this image then your serial is exposed to public."
fi
else
# start build of community kopano
hash jq > /dev/null
if [ $? -ne 0 ]
if ! hash jq
then
echo "Please install jq in order to run this build script."
exit 1
fi
# query community server by h5ai API
filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$component%3A%2F&items%5Bwhat%5D=1" -H \
"Accept: application/json" https://download.kopano.io/community/ | jq '.items[].href' | \
grep Debian_9.0-a | sed 's#"##g' | sed "s#/community/$component:/##")
filename=$(h5ai_query "$component")
filename=$(urldecode $filename)
currentVersion=$(echo $filename | sed -r 's#[a-z]+-([0-9_.+]+)-.*#\1#')
currentVersionDocker=$(echo $currentVersion | sed 's/+/plus/')
currentVersion=$(version_from_filename "$filename")
echo "Start building community kopano $component image version ($currentVersion)..."
set -x
# build it
docker build -t zokradonh/kopano_$component:$currentVersionDocker \
-t zokradonh/kopano_$component:latest-$branch \
-t zokradonh/kopano_$component:latest \
--build-arg KOPANO_${component^^}_VERSION=$currentVersion \
docker build --pull \
-t "zokradonh/kopano_$component:${currentVersion//+/plus}" \
-t "zokradonh/kopano_$component:latest-$branch" \
-t "zokradonh/kopano_$component:latest" \
--build-arg "KOPANO_${component^^}_VERSION=$currentVersion" \
$nocache \
$customBuildString \
${buildcontext_base}${component}
"${buildcontext_base}${component}"
set +x
fi

3
common/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM scratch
COPY common.sh /

49
common/common.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
set -eu
function urldecode { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
function version_from_filename {
echo "$1" | sed -r 's#[a-z]+-([0-9_.+]+)-.*#\1#'
}
function h5ai_query {
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-all\|Debian_9.0-amd64' | sed 's#"##g' | sed "s#/community/$1:/##")
if [ -z "${filename// }" ]; then
echo "unknown component"
exit 1
fi
filename=$(urldecode "$filename")
echo "$filename"
}
function dl_and_package_community {
# take component as first argument and fallback to core if none given
component=${1:-core}
# query community server by h5ai API
filename=$(h5ai_query "$component")
# download & extract packages
curl -s -S -L -o "$filename" https://download.kopano.io/community/"$component":/"${filename}"
tar xf "$filename"
# save buildversion
currentVersion=$(version_from_filename "$filename")
echo "$component-$currentVersion" >> /kopano/buildversion
# save disk space
rm "$filename"
mv "${filename%.tar.gz}" "$component"
# prepare directory to be apt source
cd "$component"
apt-ftparchive packages . | gzip -9c > Packages.gz
cd ".."
}

View File

@ -1,9 +1,11 @@
FROM zokradonh/kopano_common AS common
FROM debian:stretch
LABEL maintainer=az@zok.xyz \
version="2.0"
RUN mkdir -p /kopano/repo /kopano/data
RUN mkdir -p /kopano/repo /kopano/data /kopano/helper
WORKDIR /kopano/repo
ARG DEBIAN_FRONTEND=noninteractive
@ -29,29 +31,40 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
update-locale LANG=en_US.UTF-8
ARG KOPANO_CORE_VERSION=newest
ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo"
ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo/core"
ARG KOPANO_REPOSITORY_FLAGS="trusted=yes"
ARG DOWNLOAD_COMMUNITY_PACKAGES=1
ARG RELEASE_KEY_DOWNLOAD=0
ARG ADDITIONAL_KOPANO_PACKAGES
ARG ADDITIONAL_KOPANO_PACKAGES=""
# community build
COPY download_community.sh /kopano/download_community.sh
# get common utilities
COPY --from=common /common.sh /kopano/helper/
SHELL [ "/bin/bash", "-c"]
RUN \
# community download
[ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ] && \
/kopano/download_community.sh core && \
# community download and package as apt source repository
. /kopano/helper/common.sh && \
if [ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ]; then \
dl_and_package_community "core"; \
fi; \
echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \
# save kopano version if supported kopano
if [ -z /kopano/buildversion ]; then \
echo "core-${KOPANO_CORE_VERSION}" > /kopano/buildversion; \
fi; \
# install apt key if supported kopano
if [ ${RELEASE_KEY_DOWNLOAD} -eq 1 ]; then \
curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add -; \
fi; \
# 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; \
[ ${RELEASE_KEY_DOWNLOAD} -eq 1 ] && curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add -; \
apt-get update && \
set -x && \
apt-get install --no-install-recommends -y \
kopano-server-packages \
${ADDITIONAL_KOPANO_PACKAGES} \
php7.0-cli && \
set +x && \
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/ && \
@ -64,7 +77,6 @@ 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/bin/dumb-init", "--"]

View File

@ -1,29 +0,0 @@
#!/bin/bash
# take component as first argument and fallback to core if none given
component=${1:-core}
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
# query community server by h5ai API
filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$component%3A%2F&items%5Bwhat%5D=1" -H \
"Accept: application/json" https://download.kopano.io/community/ | jq '.items[].href' | \
grep 'Debian_9.0-all\|Debian_9.0-amd64' | sed 's#"##g' | sed "s#/community/$component:/##")
if [ -z "${filename// }" ]; then
echo "unknown component"
exit 1
fi
filename=$(urldecode "$filename")
# download & extract packages
curl -s -S -L -o "$filename" https://download.kopano.io/community/"$component":/"${filename}"
tar xf "$filename"
# save disk space
rm "$filename"
# prepare directory to be apt source
apt-ftparchive packages "${filename%.tar.gz}" | gzip -9c > Packages.gz

0
core/start-service.sh Normal file → Executable file
View File

View File

@ -1,29 +0,0 @@
#!/bin/bash
# take component as first argument and fallback to core if none given
component=${1:-core}
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
# query community server by h5ai API
filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$component%3A%2F&items%5Bwhat%5D=1" -H \
"Accept: application/json" https://download.kopano.io/community/ | jq '.items[].href' | \
grep 'Debian_9.0-all\|Debian_9.0-amd64' | sed 's#"##g' | sed "s#/community/$component:/##")
if [ -z "${filename// }" ]; then
echo "unknown component"
exit 1
fi
filename=$(urldecode "$filename")
# download & extract packages
curl -s -S -L -o "$filename" https://download.kopano.io/community/"$component":/"${filename}"
tar xf "$filename"
# save disk space
rm "$filename"
# prepare directory to be apt source
apt-ftparchive packages "${filename%.tar.gz}" | gzip -9c > Packages.gz

View File

@ -1,12 +1,14 @@
FROM zokradonh/kopano_common AS common
FROM debian:stretch
LABEL maintainer=az@zok.xyz \
version="2.0"
RUN mkdir -p /kopano/repo /kopano/data
RUN mkdir -p /kopano/repo /kopano/data /kopano/helper
WORKDIR /kopano/repo
ENV DEBIAN_FRONTEND noninteractive
ARG DEBIAN_FRONTEND=noninteractive
# install basics
RUN apt-get update && \
@ -25,40 +27,44 @@ RUN apt-get update && \
&& \
rm -rf /var/cache/apt /var/lib/apt/lists
# If you have active Kopano subscription you can change KOPANO_WEBAPP_REPOSITORY_URL to
# https://serial:<YOURSERIAL>@download.kopano.io/supported/webapp:/final/Debian_9.0
# and replace <YOURSERIAL> with your serial. You can also use pre-final or any other repository branch.
# docker build --build-arg KOPANO_WEBAPP_REPOSITORY_URL=https://serial:<YOURSERIAL>@download.kopano.io/supported/webapp:/final/Debian_9.0 https://github.com/zokradonh/kopano-docker.git#:webapp
# Do the same with KOPANO_CORE_REPOSITORY as webapp needs some packages from core.
# If you want to use community version please use images from hub.docker.com.
# Changing KOPANO_WEBAPP_VERSION does not really change the resulting image.
ARG KOPANO_WEBAPP_VERSION=newest
ARG KOPANO_WEBAPP_REPOSITORY_URL="file:/kopano/repo"
ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo"
ARG KOPANO_WEBAPP_REPOSITORY_URL="file:/kopano/repo/webapp"
ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo/core"
ARG KOPANO_REPOSITORY_FLAGS="trusted=yes"
ARG DOWNLOAD_COMMUNITY_PACKAGES=1
ARG RELEASE_KEY_DOWNLOAD=0
ARG ADDITIONAL_KOPANO_PACKAGES
ARG ADDITIONAL_KOPANO_PACKAGES=""
# community build
COPY download_community.sh /kopano/download_community.sh
# get common utilities
COPY --from=common /common.sh /kopano/helper/
SHELL [ "/bin/bash", "-c"]
# install kopano web app and refresh ca-certificates
RUN \
# community download
[ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ] && \
/kopano/download_community.sh core && \
/kopano/download_community.sh webapp && \
# install
set -x && \
echo ${KOPANO_CORE_VERSION} > /kopano/buildversion && \
echo ${KOPANO_WEBAPP_VERSION} >> /kopano/buildversion && \
echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano-core.list; \
[ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 0 ] && echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_WEBAPP_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano-webapp.list; \
[ ${RELEASE_KEY_DOWNLOAD} -eq 1 ] && curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add -; \
[ ${RELEASE_KEY_DOWNLOAD} -eq 1 ] && curl -s -S -o - "${KOPANO_WEBAPP_REPOSITORY_URL}/Release.key" | apt-key add -; \
# community download and package as apt source repository
. /kopano/helper/common.sh && \
if [ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ]; then \
dl_and_package_community "core"; \
dl_and_package_community "webapp"; \
fi; \
echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \
echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_WEBAPP_REPOSITORY_URL} ./" >> /etc/apt/sources.list.d/kopano.list; \
# save kopano version if supported kopano
if [ -z /kopano/buildversion ]; then \
echo "core-${KOPANO_CORE_VERSION}" > /kopano/buildversion; \
echo "webapp-${KOPANO_WEBAPP_VERSION}" >> /kopano/buildversion; \
fi; \
# install apt keys if supported kopano
if [ ${RELEASE_KEY_DOWNLOAD} -eq 1 ]; then \
curl -s -S -o - "${KOPANO_CORE_REPOSITORY_URL}/Release.key" | apt-key add -; \
curl -s -S -o - "${KOPANO_WEBAPP_REPOSITORY_URL}/Release.key" | apt-key add -; \
fi; \
# prepare z-push installation
echo "deb http://repo.z-hub.io/z-push:/final/Debian_9.0/ /" > /etc/apt/sources.list.d/zpush.list && \
curl -s -S -o - "http://repo.z-hub.io/z-push:/final/Debian_9.0/Release.key" | apt-key add - && \
# install
set -x && \
apt-get update && apt-get install -y --no-install-recommends \
apache2 \
libapache2-mod-php7.0 \
@ -131,8 +137,6 @@ EXPOSE 80/tcp
COPY start.sh /kopano/start.sh
RUN chmod a+x /kopano/start.sh
ENV LANG en_US.UTF-8
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,29 +0,0 @@
#!/bin/bash
# take component as first argument and fallback to core if none given
component=${1:-core}
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
# query community server by h5ai API
filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$component%3A%2F&items%5Bwhat%5D=1" -H \
"Accept: application/json" https://download.kopano.io/community/ | jq '.items[].href' | \
grep 'Debian_9.0-all\|Debian_9.0-amd64' | sed 's#"##g' | sed "s#/community/$component:/##")
if [ -z "${filename// }" ]; then
echo "unknown component"
exit 1
fi
filename=$(urldecode "$filename")
# download & extract packages
curl -s -S -L -o "$filename" https://download.kopano.io/community/"$component":/"${filename}"
tar xf "$filename"
# save disk space
rm "$filename"
# prepare directory to be apt source
apt-ftparchive packages "${filename%.tar.gz}" | gzip -9c > Packages.gz

0
webapp/start.sh Normal file → Executable file
View File