From f9dd3dfa1dce4145be902dd6d0b405949c92330c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 22 Jun 2024 12:21:28 +0100 Subject: [PATCH 1/4] Add PADD branch switch to build script. Fix casing of as->AS in Dockerfile to silence a warning about casing Signed-off-by: Adam Warner --- build.sh | 7 +++++++ src/Dockerfile | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 22d7e7c8..61f4a58b 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,7 @@ usage() { echo " -f, --ftlbranch Specify FTL branch (cannot be used in conjunction with -l)" echo " -c, --corebranch Specify Core branch" echo " -w, --webbranch Specify Web branch" + echo " -p, --paddbranch Specify PADD branch" echo " -t, --tag Specify Docker image tag (default: pihole)" echo " -l, --local Use locally built FTL binary (requires src/pihole-FTL file)" echo " use_cache Enable caching (by default --no-cache is used)" @@ -61,6 +62,12 @@ while [[ $# -gt 0 ]]; do shift shift ;; + -p | --paddbranch) + PADD_BRANCH="$2" + DOCKER_BUILD_CMD+=" --build-arg PADD_BRANCH=$PADD_BRANCH" + shift + shift + ;; -t | --tag) TAG="$2" DOCKER_BUILD_CMD=${DOCKER_BUILD_CMD/pihole/$TAG} diff --git a/src/Dockerfile b/src/Dockerfile index b5422637..939be156 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 ARG FTL_SOURCE=remote ARG alpine_version="3.19" -FROM alpine:${alpine_version} as base +FROM alpine:${alpine_version} AS base # https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope ARG TARGETPLATFORM @@ -69,7 +69,7 @@ COPY --chmod=0755 start.sh /usr/bin/start.sh ## Buildkit can do some fancy stuff and we can use it to either download FTL from ftl.pi-hole.net or use a local copy -FROM base as remote-ftl-install +FROM base AS remote-ftl-install # Default stage if FTL_SOURCE is not explicitly set to "local" # Download the latest version of pihole-FTL for the correct architecture RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then FTLARCH=amd64; \ @@ -85,12 +85,12 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then FTLARCH=amd64; \ && chmod +x /usr/bin/pihole-FTL \ && readelf -h /usr/bin/pihole-FTL || cat /usr/bin/pihole-FTL -FROM base as local-ftl-install +FROM base AS local-ftl-install # pihole-FTL must be built from source and copied to the build directory first! COPY --chmod=0755 pihole-FTL /usr/bin/pihole-FTL # Use the appropriate FTL Install stage based on the FTL_SOURCE build-arg -FROM ${FTL_SOURCE}-ftl-install as final +FROM ${FTL_SOURCE}-ftl-install AS final HEALTHCHECK CMD dig +short +norecurse +retry=0 @127.0.0.1 pi.hole || exit 1 From 425ecb39b83a54eee3121b42eb091adbcd09d8f8 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 22 Jun 2024 12:31:15 +0100 Subject: [PATCH 2/4] Not sure how this ever worked, or why it has suddenly started causing issues if it did work. Remove trailing `.` from the pytest version in requirements.txt Signed-off-by: Adam Warner --- .github/workflows/build-and-test.yml | 4 ++-- test/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e5f20418..598f908b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -19,7 +19,7 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: - platforms: ${{ matrix.platform}} + platforms: ${{ matrix.platform }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -27,4 +27,4 @@ jobs: - name: Run Tests run: | echo "Building image to test" - PLATFORM=${{ matrix.platform}} ./build-and-test.sh \ No newline at end of file + PLATFORM=${{ matrix.platform }} ./build-and-test.sh \ No newline at end of file diff --git a/test/requirements.txt b/test/requirements.txt index e41b1947..6782a069 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,4 +1,4 @@ -pytest == 7.4. +pytest == 7.4 pytest-xdist == 3.5.0 pytest-testinfra == 10.0.0 black == 23.12.0 From 20145db333f05fa92bd01715cb53f886899a7f8a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 22 Jun 2024 12:44:12 +0100 Subject: [PATCH 3/4] silende JSONArgsRecommended warning in test build Signed-off-by: Adam Warner --- test/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Dockerfile b/test/Dockerfile index 2380232d..da65f292 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -18,5 +18,5 @@ RUN apk add --no-cache \ # Tests fall over without it. Investigate later. && sed -i 's|/bin/sh|/bin/bash|g' /usr/lib/python3.11/site-packages/testinfra/backend/docker.py -ENTRYPOINT entrypoint.sh -CMD cmd.sh +ENTRYPOINT ["/bin/sh","-c","entrypoint.sh"] +CMD ["/bin/sh","-c","cmd.sh"] From d28c37e1e50ff54d2764e021f27cfcf5690e9e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 24 Jun 2024 18:17:24 +0200 Subject: [PATCH 4/4] Remove entrypoint.sh as it is not needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- build-and-test.sh | 5 +++-- test/Dockerfile | 5 ++--- test/entrypoint.sh | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 test/entrypoint.sh diff --git a/build-and-test.sh b/build-and-test.sh index 3c34bbdb..c56b0c83 100755 --- a/build-and-test.sh +++ b/build-and-test.sh @@ -2,7 +2,8 @@ set -ex if [[ "$1" == "enter" ]]; then - enter="-it --entrypoint=sh" + enter="-it" + cmd="sh" fi GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed "s/\//-/g") @@ -20,4 +21,4 @@ docker run --rm \ --env GIT_TAG="${GIT_TAG}" \ --env PY_COLORS=1 \ --env TARGETPLATFORM="${PLATFORM}" \ - ${enter} image_pipenv + ${enter} image_pipenv ${cmd} diff --git a/test/Dockerfile b/test/Dockerfile index da65f292..fa2ceb95 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -4,7 +4,6 @@ ARG docker_version="25.0.4" FROM docker:${docker_version}-cli-alpine${alpine_version} COPY --chmod=0755 ./cmd.sh /usr/local/bin/cmd.sh -COPY --chmod=0755 ./entrypoint.sh /usr/local/bin/entrypoint.sh COPY requirements.txt /root/ WORKDIR /root @@ -18,5 +17,5 @@ RUN apk add --no-cache \ # Tests fall over without it. Investigate later. && sed -i 's|/bin/sh|/bin/bash|g' /usr/lib/python3.11/site-packages/testinfra/backend/docker.py -ENTRYPOINT ["/bin/sh","-c","entrypoint.sh"] -CMD ["/bin/sh","-c","cmd.sh"] +SHELL ["/bin/sh", "-c"] +CMD ["cmd.sh"] diff --git a/test/entrypoint.sh b/test/entrypoint.sh deleted file mode 100644 index dce4fc19..00000000 --- a/test/entrypoint.sh +++ /dev/null @@ -1 +0,0 @@ -set -ex && cmd.sh \ No newline at end of file