diff --git a/.env b/.env index 37dbc67..5cbee27 100644 --- a/.env +++ b/.env @@ -1,8 +1,6 @@ # don't forget to add the minus before the version -# example: VERSION=-3.2.0-12 IMAGE_REPO=zammad/zammad-docker-compose -VERSION=-3.2.0-13 -RESTART=always -POSTGRES_USER=zammad POSTGRES_PASS=zammad - +POSTGRES_USER=zammad +RESTART=always +VERSION=-3.2.0-13 diff --git a/.github/lint-scripts.sh b/.github/lint-scripts.sh index 194b74d..7bf2204 100755 --- a/.github/lint-scripts.sh +++ b/.github/lint-scripts.sh @@ -5,15 +5,9 @@ set -o errexit -CONFIG_DIR=".github" -HOOKS_DIR="hooks" -CONTAINER_DIR="containers" - TMP_FILE="$(mktemp)" -find "${CONFIG_DIR}" -type f -name "*.sh" > "${TMP_FILE}" -find "${HOOKS_DIR}" -type f -name "*.sh" >> "${TMP_FILE}" -find "${CONTAINER_DIR}" -type f -name "*.sh" >> "${TMP_FILE}" +find . -type f -name "*.sh" > "${TMP_FILE}" while read -r FILE; do echo lint "${FILE}" diff --git a/.github/tests.sh b/.github/tests.sh new file mode 100755 index 0000000..5a2dbd3 --- /dev/null +++ b/.github/tests.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# run zammad tests +# + +set -o errexit +set -o pipefail + +docker-compose logs --timestamps --follow & + +until (curl -I --silent --fail localhost | grep -iq "HTTP/1.1 200 OK"); do + echo "wait for zammad to be ready..." + sleep 15 +done + +sleep 10 + +echo +echo "Success - Zammad is up :)" +echo diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2ea4e55..2e7ae51 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,14 +14,37 @@ jobs: with: args: .github/lint-scripts.sh - install-docker-compose: - name: install-docker-compose + lint-docker-files: runs-on: ubuntu-latest needs: lint-bash-scripts + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: lint zammad dockerfile + uses: brpaz/hadolint-action@master + with: + dockerfile: containers/zammad-elasticsearch/Dockerfile + - name: lint elasticsearch dockerfile + uses: brpaz/hadolint-action@master + with: + dockerfile: containers/zammad-postgresql/Dockerfile + - name: lint postgresql dockerfile + uses: brpaz/hadolint-action@master + with: + dockerfile: containers/zammad/Dockerfile + + test-docker-compose: + timeout-minutes: 30 + runs-on: ubuntu-latest + needs: lint-docker-files steps: - name: Checkout uses: actions/checkout@v1 - - name: get containers + - name: pull container images run: docker-compose pull - - name: install - run: docker-compose up + - name: run docker-compose up + run: docker-compose up --detach + - name: run tests + run: .github/tests.sh + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7ea740b..b5001d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -MAINTAINER Zammad ARG BUILD_DATE LABEL org.label-schema.build-date="$BUILD_DATE" \ diff --git a/containers/zammad-elasticsearch/Dockerfile b/containers/zammad-elasticsearch/Dockerfile index 3321a17..99f5e06 100644 --- a/containers/zammad-elasticsearch/Dockerfile +++ b/containers/zammad-elasticsearch/Dockerfile @@ -1,5 +1,4 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.6.0 -MAINTAINER Zammad ARG BUILD_DATE LABEL org.label-schema.build-date="$BUILD_DATE" \ @@ -13,4 +12,6 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.schema-version="3.2.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" +SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"] + RUN yes | /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment diff --git a/containers/zammad-postgresql/Dockerfile b/containers/zammad-postgresql/Dockerfile index d40260b..bacf81c 100644 --- a/containers/zammad-postgresql/Dockerfile +++ b/containers/zammad-postgresql/Dockerfile @@ -1,6 +1,5 @@ FROM postgres:9.6.17-alpine -MAINTAINER Zammad ARG BUILD_DATE LABEL org.label-schema.build-date="$BUILD_DATE" \ @@ -14,6 +13,8 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.schema-version="3.2.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" +SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"] + # copy backup script COPY containers/zammad-postgresql/backup.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/backup.sh diff --git a/containers/zammad-postgresql/backup.sh b/containers/zammad-postgresql/backup.sh old mode 100644 new mode 100755 index 77793b5..6774d76 --- a/containers/zammad-postgresql/backup.sh +++ b/containers/zammad-postgresql/backup.sh @@ -33,7 +33,7 @@ function zammad_backup { fi #db backup - pg_dump --dbname=postgresql://"${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}"@"${POSTGRESQL_HOST}":"${POSTGRESQL_PORT}"/"${POSTGRESQL_DB}" | gzip > "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_db.psql.gz + pg_dump --dbname=postgresql://"${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@${POSTGRESQL_HOST}:${POSTGRESQL_PORT}/${POSTGRESQL_DB}" | gzip > "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_db.psql.gz } if [ "$1" = 'zammad-backup' ]; then diff --git a/containers/zammad/Dockerfile b/containers/zammad/Dockerfile index 0403b77..8fb92f5 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -2,7 +2,6 @@ FROM ruby:2.5.5-slim AS builder # note: zammad is currently incompatible to alpine because of: # https://github.com/docker-library/ruby/issues/113 -MAINTAINER Zammad ARG BUILD_DATE ARG DEBIAN_FRONTEND=noninteractive @@ -17,6 +16,8 @@ ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH} ENV ZAMMAD_USER zammad +SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"] + # install zammad COPY containers/zammad/setup.sh /tmp RUN chmod +x /tmp/setup.sh; \ @@ -25,7 +26,6 @@ RUN chmod +x /tmp/setup.sh; \ FROM ruby:2.5.5-slim -MAINTAINER Zammad ARG BUILD_DATE ARG DEBIAN_FRONTEND=noninteractive diff --git a/containers/zammad/setup.sh b/containers/zammad/setup.sh old mode 100644 new mode 100755 index 8446462..822b8d8 --- a/containers/zammad/setup.sh +++ b/containers/zammad/setup.sh @@ -10,6 +10,7 @@ fi apt-get update apt-get upgrade -y +# shellcheck disable=SC2086 apt-get install -y --no-install-recommends ${PACKAGES} rm -rf /var/lib/apt/lists/*