From c5c1db541a05f18480169490ee92146a8883a3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Fri, 4 Nov 2022 19:30:32 +0100 Subject: [PATCH] update zammad & components (#307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Bauer Signed-off-by: André Bauer --- .env | 2 +- .github/dependabot.yml | 14 ---- .github/docker-image-build.sh | 9 +-- .github/workflows/ci-remote-image.yaml | 2 +- .github/workflows/ci.yaml | 6 +- README.md | 64 +++++++++++++++---- containers/zammad-elasticsearch/Dockerfile | 17 ----- containers/zammad-postgresql/Dockerfile | 20 ------ containers/zammad/Dockerfile | 2 +- docker-compose.override-local.yml | 9 --- docker-compose.yml | 15 ++--- .../zammad-postgresql => scripts}/backup.sh | 2 + 12 files changed, 71 insertions(+), 91 deletions(-) delete mode 100644 containers/zammad-elasticsearch/Dockerfile delete mode 100644 containers/zammad-postgresql/Dockerfile rename {containers/zammad-postgresql => scripts}/backup.sh (98%) diff --git a/.env b/.env index c98fdde..3dab01a 100644 --- a/.env +++ b/.env @@ -5,4 +5,4 @@ POSTGRES_USER=zammad REDIS_URL=redis://zammad-redis:6379 RESTART=always # don't forget to add the minus before the version -VERSION=-5.2.3-18 +VERSION=-5.2.3-32 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d991fb6..55fceac 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,20 +8,6 @@ updates: time: "09:00" timezone: "Europe/Berlin" - - package-ecosystem: "docker" - directory: "/containers/zammad-elasticsearch" - schedule: - interval: "weekly" - time: "09:00" - timezone: "Europe/Berlin" - - - package-ecosystem: "docker" - directory: "/containers/zammad-postgresql" - schedule: - interval: "weekly" - time: "09:00" - timezone: "Europe/Berlin" - - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/docker-image-build.sh b/.github/docker-image-build.sh index d119540..fbe0f14 100755 --- a/.github/docker-image-build.sh +++ b/.github/docker-image-build.sh @@ -5,10 +5,7 @@ set -o errexit set -o pipefail -DOCKER_IMAGES="zammad zammad-elasticsearch zammad-postgresql" +DOCKER_IMAGE="zammad" -# shellcheck disable=SC2153 -for DOCKER_IMAGE in ${DOCKER_IMAGES}; do - echo "Build Zammad Docker image ${DOCKER_IMAGE} for local or ci tests" - docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_IMAGE}-local" -f "containers/${DOCKER_IMAGE}/Dockerfile" . -done +echo "Build Zammad Docker image ${DOCKER_IMAGE} for local or ci tests" +docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_IMAGE}-local" -f "containers/${DOCKER_IMAGE}/Dockerfile" . diff --git a/.github/workflows/ci-remote-image.yaml b/.github/workflows/ci-remote-image.yaml index 327c995..1f387b9 100644 --- a/.github/workflows/ci-remote-image.yaml +++ b/.github/workflows/ci-remote-image.yaml @@ -9,7 +9,7 @@ on: jobs: run-remote-image-docker-compose: timeout-minutes: 20 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7dd6458..5fbfed3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ on: jobs: lint-docker-compose-file: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 @@ -15,7 +15,7 @@ jobs: run: docker-compose config super-linter: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout Code uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: - lint-docker-compose-file - super-linter timeout-minutes: 20 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/README.md b/README.md index d26066a..087e956 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,59 @@ Elasticsearch is enabled by default in the example `docker-compose.yml` file. It ## Upgrading +### From =< to 5.0.0 to 5.2.3-32 + +* Elasticsearch was updated from 7.17.3 to 8.5.0 using the Bitnami image + * We don't use a custom build of the docker image anymore as ingest-attachment is no longer a plugin but instead a module packaged with this distribution of Elasticsearch + * ELASTICSEARCH_REINDEX var should be set to true + +* PostgreSql was updated from 9.6.24 to 15.0.0 + * We don't use a custom build of the docker image anymore as we just mount the backup script to the postgres container now + * backup / restore ins needed to update + * you can create a new backup (with your old postgres 9.6 version / still in previous git version) by: + * if you already have checked out the newest commit + * `git checkout cd424e98689b8dc49878a37b9aab67192c36fd24` + * docker-compose stop + * docker-compose up + * check docker logs until "backup finished :)" is shown as last(!) entry + * `docker logs -f zammad-docker-compose_zammad-backup_1` + * `docker-compose stop` + * you can restore the backup in postgres 15 like + * update git epository + * `git checkout master` + * `git pull` + * stop docker-compose if it's running + * `docker-compose stop` + * delete old zammad postgre container and volume (data is lost! get sure your backups are in place!) + * `docker container rm zammad-docker-compose_zammad-postgresql_1` + * `docker volume rm zammad-docker-compose_postgresql-data` + * recreate zammads postgres volume + * `docker volume create zammad-docker-compose_postgresql-data` + * start a temporary restore container (adjust username & password vars if needed) + * `docker run -it --rm --name postgres-restore -v zammad-docker-compose_zammad-backup:/var/tmp/zammad:ro -v zammad-docker-compose_postgresql-data:/var/lib/postgresql/data -e POSTGRES_USER=zammad -e POSTGRES_PASSWORD=zammad postgres:15.0-alpine` + * in a second bash shell run: + * show available backups + * `docker exec -it postgres-restore bash -c "ls -al /var/tmp/zammad/"` + * create zammad_production db + * `docker exec -it postgres-restore bash -c "psql -U zammad --command='CREATE DATABASE zammad_production'"` + * restore old data with adjusted filename you got from the ls command above + * `docker exec -it postgres-restore bash -c "gunzip -kc /var/tmp/zammad/!!!ENTER_PSQL_FILE_NAME_FROM_COMMAND_ABOVE!!!_zammad_db.psql.gz | psql -U zammad" -d zammad_production` + * stop the restore container + * `docker stop postgres-restore` + * in your first bash shell + * `docker-compose up` + +### From =< 4.0.0 to 5.0.0 + +Memchached config changed. If you use the old env vars `MEMCACHED_HOST` & `MEMCACHED_PORT` adapt to `MEMCACHE_SERVERS`. +Redis is a dependency for the Websocket server now. + +### From =< 3.6.0-65 + +To be able to run Zammad container with an unprivileged user we had to change the port Nginx uses from 80 to 8080, so Zammad needs to be accessed via instead of now! + +This change will also affect you, if you use a reverse proxy, like Traefik or Haproxy, in front of Zammad as your reverse proxy configuration needs to be adapted to point to port 8080 now. + ### From =< 3.3.0-12 We've updated the Elasticsearch image from 5.6 to 7.6. @@ -69,14 +122,3 @@ CREATE USER zammad; ALTER USER zammad WITH PASSWORD 'zammad'; ALTER USER zammad WITH SUPERUSER CREATEDB; ``` - -### From =< 3.6.0-65 - -To be able to run Zammad container with an unprivileged user we had to change the port Nginx uses from 80 to 8080, so Zammad needs to be accessed via instead of now! - -This change will also affect you, if you use a reverse proxy, like Traefik or Haproxy, in front of Zammad as your reverse proxy configuration needs to be adapted to point to port 8080 now. - -### From =< 4.0.0 to 5.0.0 - -Memchached config changed. If you use the old env vars `MEMCACHED_HOST` & `MEMCACHED_PORT` adapt to `MEMCACHE_SERVERS`. -Redis is a dependency for the Websocket server now. diff --git a/containers/zammad-elasticsearch/Dockerfile b/containers/zammad-elasticsearch/Dockerfile deleted file mode 100644 index a4ea30c..0000000 --- a/containers/zammad-elasticsearch/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.3 -ARG BUILD_DATE - -LABEL org.label-schema.build-date="$BUILD_DATE" \ - org.label-schema.name="Zammad" \ - org.label-schema.license="AGPL-3.0" \ - org.label-schema.description="Docker container for Zammad - Elasticsearch" \ - org.label-schema.url="https://zammad.org" \ - org.label-schema.vcs-url="https://github.com/zammad/zammad" \ - org.label-schema.vcs-type="Git" \ - org.label-schema.vendor="Zammad" \ - org.label-schema.schema-version="5.2.1" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" - -SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"] - -RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment diff --git a/containers/zammad-postgresql/Dockerfile b/containers/zammad-postgresql/Dockerfile deleted file mode 100644 index 1d29c2c..0000000 --- a/containers/zammad-postgresql/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM postgres:15.0-alpine - -ARG BUILD_DATE - -LABEL org.label-schema.build-date="$BUILD_DATE" \ - org.label-schema.name="Zammad" \ - org.label-schema.license="AGPL-3.0" \ - org.label-schema.description="Docker container for Zammad - Postgresql" \ - org.label-schema.url="https://zammad.org" \ - org.label-schema.vcs-url="https://github.com/zammad/zammad" \ - org.label-schema.vcs-type="Git" \ - org.label-schema.vendor="Zammad" \ - org.label-schema.schema-version="5.2.1" \ - 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/Dockerfile b/containers/zammad/Dockerfile index 5d3702e..7c898d2 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -37,7 +37,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-url="https://github.com/zammad/zammad" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ - org.label-schema.schema-version="5.2.1" \ + org.label-schema.schema-version="5.2.3" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" ENV GIT_BRANCH stable diff --git a/docker-compose.override-local.yml b/docker-compose.override-local.yml index f10bab4..375b373 100644 --- a/docker-compose.override-local.yml +++ b/docker-compose.override-local.yml @@ -3,21 +3,12 @@ version: '3' services: - zammad-backup: - image: zammad-postgresql-local - - zammad-elasticsearch: - image: zammad-elasticsearch-local - zammad-init: image: zammad-local zammad-nginx: image: zammad-local - zammad-postgresql: - image: zammad-postgresql-local - zammad-railsserver: image: zammad-local diff --git a/docker-compose.yml b/docker-compose.yml index 1bb3692..0f9a897 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,19 +14,18 @@ services: - HOLD_DAYS=10 - POSTGRESQL_USER=${POSTGRES_USER} - POSTGRESQL_PASSWORD=${POSTGRES_PASS} - image: ${IMAGE_REPO}:zammad-postgresql${VERSION} + image: postgres:15.0-alpine restart: ${RESTART} volumes: - zammad-backup:/var/tmp/zammad - - zammad-data:/opt/zammad + - zammad-data:/opt/zammad:ro + - ./scripts/backup.sh:/usr/local/bin/backup.sh:ro zammad-elasticsearch: - environment: - - discovery.type=single-node - image: ${IMAGE_REPO}:zammad-elasticsearch${VERSION} + image: bitnami/elasticsearch:8.5.0 restart: ${RESTART} volumes: - - elasticsearch-data:/usr/share/elasticsearch/data + - elasticsearch-data:/bitnami/elasticsearch/data zammad-init: command: ["zammad-init"] @@ -44,7 +43,7 @@ services: zammad-memcached: command: memcached -m 256M - image: memcached:1.6.10-alpine + image: memcached:1.6.17-alpine restart: ${RESTART} zammad-nginx: @@ -62,7 +61,7 @@ services: environment: - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASS} - image: ${IMAGE_REPO}:zammad-postgresql${VERSION} + image: postgres:15.0-alpine restart: ${RESTART} volumes: - postgresql-data:/var/lib/postgresql/data diff --git a/containers/zammad-postgresql/backup.sh b/scripts/backup.sh similarity index 98% rename from containers/zammad-postgresql/backup.sh rename to scripts/backup.sh index 6c570ee..3874ed6 100755 --- a/containers/zammad-postgresql/backup.sh +++ b/scripts/backup.sh @@ -34,6 +34,8 @@ function zammad_backup { #db backup pg_dump --dbname=postgresql://"${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@${POSTGRESQL_HOST}:${POSTGRESQL_PORT}/${POSTGRESQL_DB}" | gzip > "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_db.psql.gz + + echo "backup finished :)" } if [ "$1" = 'zammad-backup' ]; then