From 6a14fbe174b685812821f8c1d24b1cac4b8e56db Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Mon, 28 Jan 2019 11:07:06 +0100 Subject: [PATCH] build fixes and readme improvements (#85) * add compose to the build image * update readme * fine tuning for build container * directly pass commands to run script in build env * fix dockerfile so that everything can be build on Docker version 17.05.0-ce, build 9f07f0e-synology --- README.md | 6 +++--- build/Dockerfile | 6 ++++-- build/README.md | 9 +++++++-- build/run.sh | 6 ++++-- core/Dockerfile | 6 ++++++ webapp/Dockerfile | 17 +++++++++++++++-- zpush/Dockerfile | 8 ++++++++ 7 files changed, 47 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fd529c2..1dc137c 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ To get a quick impression of Kopano this git repository bundles a locally build - Destroy local containers and network interfaces: `docker-compose down` - Destroy volumes as well (will completely reset the containers, **deletes all data**): `docker-compose down -v` - Run commands in a running container: `docker-compose exec kopano_server kopano-cli --list-users` -- Get logs of a container running in the background: `docker-compose logs -f kopano_server` -- Run a `kopano-backup`: `docker run -it -v /var/run/kopano/:/var/run/kopano -v $(pwd):/kopano/path zokradonh/kopano_utils kopano-backup` -- Get a shell in a new container to for example run `kopano-migration-pst`: `docker run -it -v /var/run/kopano/:/var/run/kopano -v $(pwd):/kopano/path zokradonh/kopano_utils` (to directly run kopano-migration-pst just append it to the command) +- Get logs of a in the background running container: `docker-compose logs -f kopano_server` +- Run a `kopano-backup`: `docker run --rm -it -v /var/run/kopano/:/var/run/kopano -v $(pwd):/kopano/path zokradonh/kopano_utils kopano-backup` +- Get a shell in a new container to (for example) run `kopano-migration-pst`: `docker run --rm -it -v /var/run/kopano/:/var/run/kopano -v $(pwd):/kopano/path zokradonh/kopano_utils` (to directly run kopano-migration-pst just append it to the command) ## Third party docker images diff --git a/build/Dockerfile b/build/Dockerfile index 830fdfb..4a4b90c 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,6 @@ -FROM docker:18.09.0 -RUN apk add bash curl expect make nano jq +FROM docker:18.09.1 +ENV COMPOSE_VERSION "1.23.2" +RUN apk add bash curl expect make nano jq py-pip +RUN pip install --no-cache-dir docker-compose==${COMPOSE_VERSION} WORKDIR /kopano-docker CMD ["bash"] diff --git a/build/README.md b/build/README.md index 88be43e..99a0651 100644 --- a/build/README.md +++ b/build/README.md @@ -1,13 +1,18 @@ -Helper container for systems where build requirements (bash, curl, jq, make) are not available (for example on Synology) +# Minimal build environment + +Helper container for systems where build requirements (bash, curl, docker-compose, jq, make) are not available (for example on Synology) Run the following command to enter the "build environment" (command may need to be run with `sudo` to work with the `docker` command): ``` $ ./run.sh +This script may need to be run as root to be able to use docker/docker-compose through it. bash-4.4$ ``` +(the first time it will take a moment before the bash prompt is displayed, since the container is built locally first) + Afterwards you can execute the `setup.sh` script, modify `.env` to your liking and run any make commands: ``` @@ -63,4 +68,4 @@ Sending build context to Docker daemon 4.608kB [...] ``` -After exiting the container run `docker-compose up -d`, which will have the images started you previously built. +This container also includes ´docker-compose´ for systems that can not be easily updated (again Synology). You can freely choose to use ´docker-compose up -d´ from inside of outside of this container. diff --git a/build/run.sh b/build/run.sh index fa9e8c0..7e056e9 100755 --- a/build/run.sh +++ b/build/run.sh @@ -1,8 +1,10 @@ #!/bin/sh +if [ ! $(id -u) -eq 0 ]; then + echo "This script may need to be run as root to be able to use docker/docker-compose through it." +fi docker run \ --rm -it \ -u $(id -u ${USER}):$(id -g ${USER}) \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ${PWD}/..:/kopano-docker/ \ - $(docker build -q .) - + $(docker build -q .) $@ diff --git a/core/Dockerfile b/core/Dockerfile index 5f4dbe4..ba2457d 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -4,11 +4,17 @@ FROM ${docker_repo}/kopano_base ARG DEBIAN_FRONTEND=noninteractive ARG ADDITIONAL_KOPANO_PACKAGES="" +ENV ADDITIONAL_KOPANO_PACKAGES=$ADDITIONAL_KOPANO_PACKAGES ARG DOWNLOAD_COMMUNITY_PACKAGES=1 +ENV DOWNLOAD_COMMUNITY_PACKAGES=$DOWNLOAD_COMMUNITY_PACKAGES ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo/core" +ENV KOPANO_CORE_REPOSITORY_URL=$KOPANO_CORE_REPOSITORY_URL ARG KOPANO_CORE_VERSION=newest +ENV KOPANO_CORE_VERSION=$KOPANO_CORE_VERSION ARG KOPANO_REPOSITORY_FLAGS="trusted=yes" +ENV KOPANO_REPOSITORY_FLAGS=$KOPANO_REPOSITORY_FLAGS ARG RELEASE_KEY_DOWNLOAD=0 +ENV RELEASE_KEY_DOWNLOAD=$RELEASE_KEY_DOWNLOAD # install Kopano Core and refresh ca-certificates RUN \ diff --git a/webapp/Dockerfile b/webapp/Dockerfile index bbb39f2..3cd7fd3 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -4,22 +4,35 @@ FROM ${docker_repo}/kopano_base ARG DEBIAN_FRONTEND=noninteractive ARG ADDITIONAL_KOPANO_PACKAGES="" +ENV ADDITIONAL_KOPANO_PACKAGES=$ADDITIONAL_KOPANO_PACKAGES ARG ADDITIONAL_KOPANO_WEBAPP_PLUGINS="" +ENV ADDITIONAL_KOPANO_WEBAPP_PLUGINS=$ADDITIONAL_KOPANO_WEBAPP_PLUGINS ARG DOWNLOAD_COMMUNITY_PACKAGES=1 +ENV DOWNLOAD_COMMUNITY_PACKAGES=$DOWNLOAD_COMMUNITY_PACKAGES ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo/core" +ENV KOPANO_CORE_REPOSITORY_URL=$KOPANO_CORE_REPOSITORY_URL ARG KOPANO_REPOSITORY_FLAGS="trusted=yes" +ENV KOPANO_REPOSITORY_FLAGS=$KOPANO_REPOSITORY_FLAGS ARG KOPANO_WEBAPP_REPOSITORY_URL="file:/kopano/repo/webapp" +ENV KOPANO_WEBAPP_REPOSITORY_URL=$KOPANO_WEBAPP_REPOSITORY_URL ARG KOPANO_WEBAPP_SMIME_REPOSITORY_URL="file:/kopano/repo/smime" +ENV KOPANO_WEBAPP_SMIME_REPOSITORY_URL=$KOPANO_WEBAPP_SMIME_REPOSITORY_URL ARG KOPANO_WEBAPP_MDM_REPOSITORY_URL="file:/kopano/repo/mdm" +ENV KOPANO_WEBAPP_MDM_REPOSITORY_URL=$KOPANO_WEBAPP_MDM_REPOSITORY_URL ARG KOPANO_WEBAPP_FILES_REPOSITORY_URL="file:/kopano/repo/files" +ENV KOPANO_WEBAPP_FILES_REPOSITORY_URL=$KOPANO_WEBAPP_FILES_REPOSITORY_URL ARG KOPANO_CORE_VERSION=newest +ENV KOPANO_CORE_VERSION=$KOPANO_CORE_VERSION ARG KOPANO_WEBAPP_VERSION=newest +ENV KOPANO_WEBAPP_VERSION=$KOPANO_WEBAPP_VERSION ARG KOPANO_WEBAPP_FILES_VERSION=newest +ENV KOPANO_WEBAPP_FILES_VERSION=$KOPANO_WEBAPP_FILES_VERSION ARG KOPANO_WEBAPP_MDM_VERSION=newest +ENV KOPANO_WEBAPP_MDM_VERSION=$KOPANO_WEBAPP_MDM_VERSION ARG KOPANO_WEBAPP_SMIME_VERSION=newest +ENV KOPANO_WEBAPP_SMIME_VERSION=$KOPANO_WEBAPP_SMIME_VERSION ARG RELEASE_KEY_DOWNLOAD=0 - -ENV ADDITIONAL_KOPANO_WEBAPP_PLUGINS="" +ENV RELEASE_KEY_DOWNLOAD=$RELEASE_KEY_DOWNLOAD # install Kopano WebApp and refresh ca-certificates RUN \ diff --git a/zpush/Dockerfile b/zpush/Dockerfile index 46446c7..5efe1f2 100644 --- a/zpush/Dockerfile +++ b/zpush/Dockerfile @@ -4,13 +4,21 @@ FROM ${docker_repo}/kopano_base ARG DEBIAN_FRONTEND=noninteractive ARG ADDITIONAL_KOPANO_PACKAGES="" +ENV ADDITIONAL_KOPANO_PACKAGES=$ADDITIONAL_KOPANO_PACKAGES ARG DOWNLOAD_COMMUNITY_PACKAGES=1 +ENV DOWNLOAD_COMMUNITY_PACKAGES=$DOWNLOAD_COMMUNITY_PACKAGES ARG KOPANO_CORE_REPOSITORY_URL="file:/kopano/repo/core" +ENV KOPANO_CORE_REPOSITORY_URL=$KOPANO_CORE_REPOSITORY_URL ARG KOPANO_ZPUSH_REPOSITORY_URL="http://repo.z-hub.io/z-push:/final/Debian_9.0/" +ENV KOPANO_ZPUSH_REPOSITORY_URL=$KOPANO_ZPUSH_REPOSITORY_URL ARG KOPANO_REPOSITORY_FLAGS="trusted=yes" +ENV KOPANO_REPOSITORY_FLAGS=$KOPANO_REPOSITORY_FLAGS ARG KOPANO_CORE_VERSION=newest +ENV KOPANO_CORE_VERSION=$KOPANO_CORE_VERSION ARG KOPANO_ZPUSH_VERSION=newest +ENV KOPANO_ZPUSH_VERSION=$KOPANO_ZPUSH_VERSION ARG RELEASE_KEY_DOWNLOAD=0 +ENV RELEASE_KEY_DOWNLOAD=$RELEASE_KEY_DOWNLOAD # install Kopano WebApp and refresh ca-certificates RUN \