From e99e29a0b91f4de3507553ed9b0b06d8890f6c8a Mon Sep 17 00:00:00 2001 From: The Oh Brothers Bot Date: Sun, 28 Apr 2024 01:23:10 +0000 Subject: [PATCH] Enhancement: Add pagefind 1.1.0 variants Signed-off-by: The Oh Brothers Bot --- .github/workflows/ci-master-pr.yml | 124 +++++++++++++++++++++++++++- README.md | 5 +- generate/definitions/versions.json | 1 + variants/1.1.0/Dockerfile | 39 +++++++++ variants/1.1.0/docker-entrypoint.sh | 8 ++ 5 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 variants/1.1.0/Dockerfile create mode 100644 variants/1.1.0/docker-entrypoint.sh diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index c23aa56..1594ea4 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-1-1-0: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - 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@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-1.1.0-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-1.1.0- + ${{ 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@v3 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + # This step generates the docker tags + - name: Prepare + id: prep-1-1-0 + 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="1.1.0" + 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: 1.1.0 - Build (PRs) + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: variants/1.1.0 + platforms: linux/386,linux/amd64,linux/arm64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 1.1.0 - Build and push (master) + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v5 + with: + context: variants/1.1.0 + platforms: linux/386,linux/amd64,linux/arm64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.REF_SHA_VARIANT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: 1.1.0 - Build and push (release) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: variants/1.1.0 + platforms: linux/386,linux/amd64,linux/arm64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.VARIANT }} + ${{ github.repository }}:${{ steps.prep-1-1-0.outputs.REF_VARIANT }} + ${{ github.repository }}:${{ steps.prep-1-1-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 + + # 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-1-0-4: runs-on: ubuntu-latest steps: @@ -141,7 +261,6 @@ jobs: ${{ github.repository }}:${{ steps.prep-1-0-4.outputs.VARIANT }} ${{ github.repository }}:${{ steps.prep-1-0-4.outputs.REF_VARIANT }} ${{ github.repository }}:${{ steps.prep-1-0-4.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 @@ -155,6 +274,7 @@ jobs: update-draft-release: needs: + - build-1-1-0 - build-1-0-4 if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest @@ -169,6 +289,7 @@ jobs: publish-draft-release: needs: + - build-1-1-0 - build-1-0-4 if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest @@ -185,6 +306,7 @@ jobs: update-dockerhub-description: needs: + - build-1-1-0 - build-1-0-4 if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest diff --git a/README.md b/README.md index 50de659..10e5b7f 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,15 @@ Dockerized [pagefind](https://github.com/CloudCannon/pagefind). | Tag | Dockerfile Build Context | |:-------:|:---------:| -| `:1.0.4`, `:latest` | [View](variants/1.0.4) | +| `:1.1.0`, `:latest` | [View](variants/1.1.0) | +| `:1.0.4` | [View](variants/1.0.4) | ## Usage Mount the public directory into the container at `/public`. ```sh -docker run --rm -it -v $(pwd)/public:/public theohbrothers/docker-pagefind:1.0.4 +docker run --rm -it -v $(pwd)/public:/public theohbrothers/docker-pagefind:1.1.0 ``` ## Development diff --git a/generate/definitions/versions.json b/generate/definitions/versions.json index 066839a..6bd2e75 100644 --- a/generate/definitions/versions.json +++ b/generate/definitions/versions.json @@ -1,6 +1,7 @@ { "pagefind": { "versions": [ + "1.1.0", "1.0.4" ], "versionsChangeScope": "minor", diff --git a/variants/1.1.0/Dockerfile b/variants/1.1.0/Dockerfile new file mode 100644 index 0000000..778292c --- /dev/null +++ b/variants/1.1.0/Dockerfile @@ -0,0 +1,39 @@ +FROM alpine:3.17 +# Install pagefind_extended +RUN set -eux; \ + PAGEFIND_EXTENDED_VERSION=v1.1.0; \ + case "$( uname -m )" in \ + 'x86') \ + URL="https://github.com/CloudCannon/pagefind/releases/download/v1.1.0/pagefind_extended-v1.1.0-x86_64-unknown-linux-musl.tar.gz"; \ + SHA256=583cf2753fb2070448a9c9cf1f31acd1b96af99b9ca0a450faf9bb376420bac4; \ + ;; \ + 'x86_64') \ + URL="https://github.com/CloudCannon/pagefind/releases/download/v1.1.0/pagefind_extended-v1.1.0-x86_64-unknown-linux-musl.tar.gz"; \ + SHA256=583cf2753fb2070448a9c9cf1f31acd1b96af99b9ca0a450faf9bb376420bac4; \ + ;; \ + 'aarch64') \ + URL="https://github.com/CloudCannon/pagefind/releases/download/v1.1.0/pagefind_extended-v1.1.0-aarch64-unknown-linux-musl.tar.gz"; \ + SHA256=b05661d856372beea75468ea683f197b465e019f033259768f65988c9598f390; \ + ;; \ + *) \ + echo "Architecture not supported"; \ + exit 1; \ + ;; \ + esac; \ + FILE=pagefind_extended.tar.gz; \ + wget -q "$URL" -O "$FILE"; \ + echo "$SHA256 $FILE" | sha256sum -c -; \ + tar -xvf "$FILE" --no-same-owner --no-same-permissions -- pagefind_extended; \ + rm -f "$FILE"; \ + mkdir -pv /usr/local/bin; \ + mv -v pagefind_extended /usr/local/bin/pagefind_extended; \ + chmod +x /usr/local/bin/pagefind_extended; \ + pagefind_extended --version; \ + : + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x docker-entrypoint.sh + +WORKDIR / +ENTRYPOINT [ "/docker-entrypoint.sh" ] +CMD [ "pagefind_extended", "--site", "/public" ] \ No newline at end of file diff --git a/variants/1.1.0/docker-entrypoint.sh b/variants/1.1.0/docker-entrypoint.sh new file mode 100644 index 0000000..28d1942 --- /dev/null +++ b/variants/1.1.0/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then + set -- pagefind_extended "$@" +fi + +exec "$@" \ No newline at end of file