From 6795b1057b34190f3643758b56f894358e63ec53 Mon Sep 17 00:00:00 2001 From: The Oh Brothers Bot Date: Thu, 16 Nov 2023 00:41:44 +0000 Subject: [PATCH] Enhancement: Add imap-backup 14.4.1 variants Signed-off-by: The Oh Brothers Bot --- .github/workflows/ci-master-pr.yml | 124 ++++++++++++++++++++++++++- README.md | 19 ++-- generate/definitions/versions.json | 1 + variants/14.4.1/Dockerfile | 13 +++ variants/14.4.1/docker-entrypoint.sh | 13 +++ 5 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 variants/14.4.1/Dockerfile create mode 100644 variants/14.4.1/docker-entrypoint.sh diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index d759847..674c003 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -33,6 +33,126 @@ jobs: run: | git diff --exit-code + build-14-4-1: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Display system info (linux) + run: | + set -e + hostname + whoami + cat /etc/*release + lscpu + free + df -h + pwd + docker info + docker version + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-14.4.1-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-14.4.1- + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub registry + # Run on master and tags + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-14-4-1 + run: | + set -e + + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' + REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) + + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + VARIANT="14.4.1" + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" + + # Pass variables to next step + echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT + echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT + + - name: 14.4.1 - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v3 + with: + context: variants/14.4.1 + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 14.4.1 - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v3 + with: + context: variants/14.4.1 + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 14.4.1 - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v3 + with: + context: variants/14.4.1 + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-14-4-1.outputs.REF_SHA_VARIANT }} + ${{ github.repository }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + build-14-3-0: runs-on: ubuntu-latest steps: @@ -141,7 +261,6 @@ jobs: ${{ github.repository }}:${{ steps.prep-14-3-0.outputs.VARIANT }} ${{ github.repository }}:${{ steps.prep-14-3-0.outputs.REF_VARIANT }} ${{ github.repository }}:${{ steps.prep-14-3-0.outputs.REF_SHA_VARIANT }} - ${{ github.repository }}:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2892,6 +3011,7 @@ jobs: update-draft-release: needs: + - build-14-4-1 - build-14-3-0 - build-14-2-0 - build-14-1-1 @@ -2929,6 +3049,7 @@ jobs: publish-draft-release: needs: + - build-14-4-1 - build-14-3-0 - build-14-2-0 - build-14-1-1 @@ -2968,6 +3089,7 @@ jobs: update-dockerhub-description: needs: + - build-14-4-1 - build-14-3-0 - build-14-2-0 - build-14-1-1 diff --git a/README.md b/README.md index eb24f34..1119d6d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ imap-backup syncs IMAP as `.mbox` backup files, in contrast to [isync](https://g | Tag | Dockerfile Build Context | |:-------:|:---------:| -| `:14.3.0`, `:latest` | [View](variants/14.3.0) | +| `:14.4.1`, `:latest` | [View](variants/14.4.1) | +| `:14.3.0` | [View](variants/14.3.0) | | `:14.2.0` | [View](variants/14.2.0) | | `:14.1.1` | [View](variants/14.1.1) | | `:14.0.0` | [View](variants/14.0.0) | @@ -46,7 +47,7 @@ See the following `docker-compose` examples: ```sh # Print command line usage -docker run --rm -it theohbrothers/docker-imap-backup:14.3.0 help +docker run --rm -it theohbrothers/docker-imap-backup:14.4.1 help # Interactive setup. See: https://github.com/joeyates/imap-backup/blob/main/docs/commands/setup.md # 1. add account @@ -57,28 +58,28 @@ docker run --rm -it theohbrothers/docker-imap-backup:14.3.0 help # 5. test connection # 13. Press (q) return to main menu # 3. save and exit -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 setup +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 setup # View backup config -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 cat /root/.imap-backup/config.json +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 cat /root/.imap-backup/config.json # Backup. See: https://github.com/joeyates/imap-backup/blob/main/docs/commands/backup.md -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 backup +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 backup # Check backup integrity (not available on <= 9.2.0) -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 local check +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 local check # Print backup stats -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 stats +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 stats # List backup files. See: https://github.com/joeyates/imap-backup/blob/main/docs/commands/backup.md -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 ls -alR /root/.imap-backup +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 ls -alR /root/.imap-backup # Restore emails from backup to IMAP server. See: https://github.com/joeyates/imap-backup/blob/main/docs/commands/restore.md docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:9.3.1 restore # Start a shell -docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.3.0 sh +docker run --rm -it -v imap-backup:/root/.imap-backup theohbrothers/docker-imap-backup:14.4.1 sh ``` ## Development diff --git a/generate/definitions/versions.json b/generate/definitions/versions.json index 96687e9..4f1141a 100644 --- a/generate/definitions/versions.json +++ b/generate/definitions/versions.json @@ -1,6 +1,7 @@ { "imap-backup": { "versions": [ + "14.4.1", "14.3.0", "14.2.0", "14.1.1", diff --git a/variants/14.4.1/Dockerfile b/variants/14.4.1/Dockerfile new file mode 100644 index 0000000..da849a6 --- /dev/null +++ b/variants/14.4.1/Dockerfile @@ -0,0 +1,13 @@ +FROM ruby:3.2-alpine3.17 + +RUN apk add --no-cache ca-certificates +RUN set -eux; \ + gem install imap-backup -v 14.4.1; \ + imap-backup help > /dev/null + +WORKDIR /root +VOLUME /root/.imap-backup + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] \ No newline at end of file diff --git a/variants/14.4.1/docker-entrypoint.sh b/variants/14.4.1/docker-entrypoint.sh new file mode 100644 index 0000000..23e909f --- /dev/null +++ b/variants/14.4.1/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -eu + +if [ $# -gt 0 ]; then + SUBCOMMANDS=$( imap-backup help | grep -E '^\s*imap-backup' | awk '{print $2}' | sort -n | uniq ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + exec imap-backup "$@" + fi +else + exec imap-backup "$@" +fi + +exec "$@"