From adfbfeb4a3672baaa70c2d5b1f1e9940ec950e10 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Sat, 15 Jun 2019 19:21:54 +0200 Subject: [PATCH] fail make target when docker wait returns with non zero output (#184) just install python3-minimal in base clear apt key todo rework test-ci to fail when the test containers exits with error code != 1 --- Makefile | 10 ++++------ base/Dockerfile | 18 ++++++++++-------- core/Dockerfile | 5 +---- docker-compose.yml | 1 - meet/Dockerfile | 4 ---- php/Dockerfile | 4 ---- python/Dockerfile | 5 ----- webapp/Dockerfile | 4 ---- zpush/Dockerfile | 1 + 9 files changed, 16 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index b4e3abd..203451e 100644 --- a/Makefile +++ b/Makefile @@ -344,15 +344,13 @@ test: ## Build and start new containers for testing (also deletes existing data test-update-env: ## Recreate containers based on updated .env. docker-compose -f $(DOCKERCOMPOSE_FILE) up -d +.PHONY: test-ci test-ci: ## Test if all containers start up docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml build - docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml up -d - docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml ps - # TODO this just echos the exit code of the kopano_test container. if this is not 0 we should do something with it. - docker wait kopano_test_1 - docker logs --tail 10 kopano_test_1 + docker-compose -f $(DOCKERCOMPOSE_FILE) up -d + docker-compose -f $(DOCKERCOMPOSE_FILE) ps + docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml run test || (docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml down -v; exit 1) docker-compose -f $(DOCKERCOMPOSE_FILE) -f tests/test-container.yml stop 2>/dev/null - docker rm kopano_test_1 test-security: ## Scan containers with Trivy for known security risks (not part of CI workflow for now). cat $(TAG_FILE) | xargs -I % sh -c 'trivy --exit-code 0 --severity HIGH --quiet --auto-refresh %' diff --git a/base/Dockerfile b/base/Dockerfile index d96e5a9..5cf9a40 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -9,7 +9,7 @@ ARG KOPANO_REPOSITORY_FLAGS="trusted=yes" ARG RELEASE_KEY_DOWNLOAD=0 ARG DEBIAN_FRONTEND=noninteractive -ENV BASE_VERSION=1.1.0 +ENV BASE_VERSION=1.2.0 LABEL maintainer=az@zok.xyz \ org.label-schema.name="Kopano base container" \ @@ -26,8 +26,6 @@ RUN mkdir -p /kopano/repo /kopano/data /kopano/helper /kopano/path WORKDIR /kopano/repo # install basics -# TODO require python3 or python3-minimal? -# TODO install apt keys if supported kopano (instead of in core, php, meet, ...) # hadolint ignore=DL3005 RUN apt-get update && \ apt-get upgrade -y && \ @@ -41,18 +39,22 @@ RUN apt-get update && \ jq \ locales \ moreutils \ - python3 \ + python3-minimal \ && \ - rm -rf /var/cache/apt /var/lib/apt/lists/* + rm -rf /var/cache/apt /var/lib/apt/lists/*; \ + # 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 + +ENV DOCKERIZE_VERSION v0.6.1 +RUN curl -L https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzvf - -C /usr/local/bin 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 -ENV DOCKERIZE_VERSION v0.6.1 -RUN curl -L https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzvf - -C /usr/local/bin - # get common utilities COPY create-kopano-repo.sh /kopano/helper/ COPY kcconf.py /kopano/ diff --git a/core/Dockerfile b/core/Dockerfile index fa2e077..588f612 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -36,11 +36,8 @@ RUN \ if [ ${DOWNLOAD_COMMUNITY_PACKAGES} -eq 1 ]; then \ dl_and_package_community "core"; \ fi; \ + # apt key has already been installed in base echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \ - # 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 apt-get update && \ set -x && \ diff --git a/docker-compose.yml b/docker-compose.yml index 9e8623a..82e30de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -238,7 +238,6 @@ services: kopano_webapp: image: ${docker_repo:-zokradonh}/kopano_webapp:${WEBAPP_VERSION:-latest} hostname: kopano_webapp - container_name: ${COMPOSE_PROJECT_NAME}_webapp depends_on: - kopano_server volumes: diff --git a/meet/Dockerfile b/meet/Dockerfile index de0f9d6..913ea48 100644 --- a/meet/Dockerfile +++ b/meet/Dockerfile @@ -40,10 +40,6 @@ RUN \ dl_and_package_community "meet"; \ fi; \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_MEET_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \ - # install apt key if supported kopano - if [ ${RELEASE_KEY_DOWNLOAD} -eq 1 ]; then \ - curl -s -S -o - "${KOPANO_MEET_REPOSITORY_URL}/Release.key" | apt-key add -; \ - fi; \ # install apt-get update && \ set -x && \ diff --git a/php/Dockerfile b/php/Dockerfile index 287761d..c3a2baf 100644 --- a/php/Dockerfile +++ b/php/Dockerfile @@ -38,10 +38,6 @@ RUN \ dl_and_package_community "core"; \ fi; \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \ - # 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 -; \ - fi; \ # install set -x && \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/python/Dockerfile b/python/Dockerfile index 0cbf554..c9d8850 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -29,7 +29,6 @@ LABEL maintainer=az@zok.xyz \ SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# add install common php dependencies # hadolint ignore=SC2129 RUN \ # community download and package as apt source repository @@ -38,10 +37,6 @@ RUN \ dl_and_package_community "core"; \ fi; \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \ - # 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 -; \ - fi; \ # install set -x && \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/webapp/Dockerfile b/webapp/Dockerfile index fa135b0..870849e 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -56,10 +56,6 @@ RUN \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_WEBAPP_SMIME_REPOSITORY_URL} ./" >> /etc/apt/sources.list.d/kopano.list; \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_WEBAPP_MDM_REPOSITORY_URL} ./" >> /etc/apt/sources.list.d/kopano.list; \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_WEBAPP_FILES_REPOSITORY_URL} ./" >> /etc/apt/sources.list.d/kopano.list; \ - # 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 -; \ - fi; \ # install set -x && \ apt-get update && apt-get install -y --no-install-recommends \ diff --git a/zpush/Dockerfile b/zpush/Dockerfile index 5dcb09c..c196671 100644 --- a/zpush/Dockerfile +++ b/zpush/Dockerfile @@ -43,6 +43,7 @@ RUN \ echo "deb [${KOPANO_REPOSITORY_FLAGS}] ${KOPANO_CORE_REPOSITORY_URL} ./" > /etc/apt/sources.list.d/kopano.list; \ # prepare z-push installation echo "deb ${KOPANO_ZPUSH_REPOSITORY_URL} /" > /etc/apt/sources.list.d/zpush.list && \ + # this is the same key as for the rest of the Kopano stack, making a separate download anyways as this may not be the case in the future curl -s -S -o - "${KOPANO_ZPUSH_REPOSITORY_URL}/Release.key" | apt-key add - && \ # install set -x && \