- Replace PIHOLE_VERSION with PIHOLE_DOCKER_TAG

- reorder some stuff in the main Dockerfile
- Remove the CORE/WEB/FTL_VERSION args/env vars
- tweaks to GHA build script after some hints from @crazy-max
- always checkout dev versions of Pi-hole for nightly build, also make sure we're using dev branch of this repo
- keep pihole checkout enabled for dev and nightly tags

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2021-12-10 20:51:35 +00:00
parent 7049b5df03
commit 9a9ee41a45
No known key found for this signature in database
GPG Key ID: 872950F3ECF2B173
9 changed files with 37 additions and 141 deletions

View File

@ -9,7 +9,6 @@ on:
release:
types: [published]
jobs:
test:
runs-on: ubuntu-latest
@ -31,26 +30,14 @@ jobs:
steps:
-
name: Checkout
if: github.event_name != 'schedule'
uses: actions/checkout@v2
-
name: Calculate the versions to use
id: variables
run: |
# If trigged by schedule then container tag will be nightly, else it's either dev or whatever the tagged version number is
PIHOLE_VERSION=$([ "${{ github.event_name == 'schedule' }}" = "true" ] && echo "nightly" || echo "${GITHUB_REF#refs/*/}")
# If we are building dev branch or nightly then we want to use the development branches of the core components
# otherwise they will be unset and the main branches will be pulled
if [ "${PIHOLE_VERSION}" = "dev" || "${PIHOLE_VERSION}" = "nightly" ]; then
CORE_VERSION=development
WEB_VERSION=devel
FTL_VERSION=development
fi
echo ::set-output name=CORE_VERSION::${CORE_VERSION}
echo ::set-output name=WEB_VERSION::${WEB_VERSION}
echo ::set-output name=FTL_VERSION::${FTL_VERSION}
echo ::set-output name=PIHOLE_VERSION::${PIHOLE_VERSION}
name: Checkout dev branch if we are building nightly
if: github.event_name == 'schedule'
uses: actions/checkout@v2
with:
ref: dev
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
@ -69,7 +56,9 @@ jobs:
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ steps.variables.outputs.PIHOLE_VERSION }}
type=schedule
type=ref,event=branch
type=ref,event=tag
-
name: Login to DockerHub
uses: docker/login-action@v1
@ -90,10 +79,7 @@ jobs:
context: .
platforms: linux/amd64, linux/arm64, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
build-args: |
CORE_VERSION=${{ steps.variables.outputs.CORE_VERSION }}
WEB_VERSION=${{ steps.variables.outputs.WEB_VERSION }}
FTL_VERSION=${{ steps.variables.outputs.FTL_VERSION }}
PIHOLE_VERSION=${{ steps.variables.outputs.PIHOLE_VERSION }}
PIHOLE_DOCKER_TAG=${{ steps.meta.outputs.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,75 +0,0 @@
name: Build & Deploy custom image manually
on:
workflow_dispatch:
inputs:
name:
description: 'Name of tag'
required: true
core:
description: 'Branch or tag of core repo'
required: false
web:
description: 'Branch or tag of web repo'
required: false
ftl:
description: 'Branch or tag of ftl repo'
required: false
jobs:
test:
runs-on: ubuntu-latest
env:
ARCH: amd64
DEBIAN_VERSION: buster
CORE_VERSION: ${{ github.event.inputs.core }}
WEB_VERSION: ${{ github.event.inputs.web }}
FTL_VERSION: ${{ github.event.inputs.ftl }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Run Tests
run: |
echo "Building ${ARCH}-${DEBIAN_VERSION}"
./gh-actions-test.sh
build-and-publish:
needs: test
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64, linux/arm64, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
build-args: |
CORE_VERSION=${{ github.event.inputs.core }}
WEB_VERSION=${{ github.event.inputs.web }}
FTL_VERSION=${{ github.event.inputs.ftl }}
PIHOLE_VERSION=${{ github.event.inputs.name }}
push: true
tags: |
${{ secrets.DOCKERHUB_NAMESPACE }}/pihole:${{ github.event.inputs.name }}
ghcr.io/${{ github.repository_owner }}/pihole:${{ github.event.inputs.name }}

View File

@ -1,28 +1,22 @@
ARG PIHOLE_BASE
FROM "${PIHOLE_BASE:-debian:buster-slim}"
ARG CORE_VERSION
ENV CORE_VERSION "${CORE_VERSION}"
ARG WEB_VERSION
ENV WEB_VERSION "${WEB_VERSION}"
ARG FTL_VERSION
ENV FTL_VERSION "${FTL_VERSION}"
ARG PIHOLE_VERSION
ENV PIHOLE_VERSION "${PIHOLE_VERSION}"
ARG PIHOLE_DOCKER_TAG
ENV PIHOLE_DOCKER_TAG "${PIHOLE_DOCKER_TAG}"
ENV S6_OVERLAY_VERSION v2.1.0.2
COPY install.sh /usr/local/bin/install.sh
ENV PIHOLE_INSTALL /etc/.pihole/automated\ install/basic-install.sh
RUN bash -ex install.sh 2>&1 && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
ENTRYPOINT [ "/s6-init" ]
ADD s6/debian-root /
COPY s6/debian-root /
COPY s6/service /usr/local/bin/service
RUN bash -ex install.sh 2>&1 && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
# php config start passes special ENVs into
ARG PHP_ENV_CONFIG
ENV PHP_ENV_CONFIG /etc/lighttpd/conf-enabled/15-fastcgi-php.conf

View File

@ -61,7 +61,7 @@ def build(docker_repo: str, arch: str, debian_version: str, hub_tag: str, show_t
time_arg = 'time' if show_time else ''
cache_arg = '--no-cache' if no_cache else ''
build_env = os.environ.copy()
build_env['PIHOLE_VERSION'] = os.environ.get('GIT_TAG', None)
build_env['PIHOLE_DOCKER_TAG'] = os.environ.get('GIT_TAG', None)
build_env['DEBIAN_VERSION'] = debian_version
build_command = f'{time_arg} docker-compose -f build.yml build {cache_arg} --pull {arch}'
print(f' ::: Building {arch} into {create_tag}')

View File

@ -202,7 +202,7 @@ setup_php_env() {
local corshosts_line="\t\t\t\"CORS_HOSTS\" => \"${CORS_HOSTS}\","
local serverip_line="\t\t\t\"ServerIP\" => \"${ServerIP}\","
local php_error_line="\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\","
local pihole_docker_tag_line="\t\t\t\"PIHOLE_DOCKER_TAG\" => \"${PIHOLE_VERSION}\","
local pihole_docker_tag_line="\t\t\t\"PIHOLE_DOCKER_TAG\" => \"${PIHOLE_DOCKER_TAG}\","
# idempotent line additions
grep -qP "$vhost_line" "$PHP_ENV_CONFIG" || \
@ -217,7 +217,7 @@ setup_php_env() {
sed -i "/bin-environment/ a\\${pihole_docker_tag_line}" "$PHP_ENV_CONFIG"
echo "Added ENV to php:"
grep -E '(VIRTUAL_HOST|CORS_HOSTS|ServerIP|PHP_ERROR_LOG)' "$PHP_ENV_CONFIG"
grep -E '(VIRTUAL_HOST|CORS_HOSTS|ServerIP|PHP_ERROR_LOG|PIHOLE_DOCKER_TAG)' "$PHP_ENV_CONFIG"
}
setup_web_port() {

View File

@ -2,42 +2,42 @@
version: "3.7"
x-common-args: &common-args
PIHOLE_VERSION: ${PIHOLE_VERSION}
PIHOLE_DOCKER_TAG: ${PIHOLE_DOCKER_TAG}
CORE_VERSION: ${CORE_VERSION}
WEB_VERSION: ${WEB_VERSION}
FTL_VERSION: ${FTL_VERSION}
services:
amd64:
image: pihole:${PIHOLE_VERSION}-amd64-${DEBIAN_VERSION:-buster}
image: pihole:${PIHOLE_DOCKER_TAG}-amd64-${DEBIAN_VERSION:-buster}
build:
context: .
args:
<<: *common-args
PIHOLE_BASE: debian:${DEBIAN_VERSION:-buster}-slim
armel:
image: pihole:${PIHOLE_VERSION}-armel-${DEBIAN_VERSION:-buster}
image: pihole:${PIHOLE_DOCKER_TAG}-armel-${DEBIAN_VERSION:-buster}
build:
context: .
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:armel-${DEBIAN_VERSION:-buster}-slim
armhf:
image: pihole:${PIHOLE_VERSION}-armhf-${DEBIAN_VERSION:-buster}
image: pihole:${PIHOLE_DOCKER_TAG}-armhf-${DEBIAN_VERSION:-buster}
build:
context: .
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:armhf-${DEBIAN_VERSION:-buster}-slim
arm64:
image: pihole:${PIHOLE_VERSION}-arm64-${DEBIAN_VERSION:-buster}
image: pihole:${PIHOLE_DOCKER_TAG}-arm64-${DEBIAN_VERSION:-buster}
build:
context: .
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:arm64-${DEBIAN_VERSION:-buster}-slim
i386:
image: pihole:${PIHOLE_VERSION}-i386-${DEBIAN_VERSION:-buster}
image: pihole:${PIHOLE_DOCKER_TAG}-i386-${DEBIAN_VERSION:-buster}
build:
context: .
args:

View File

@ -52,44 +52,35 @@ export USER=pihole
export PIHOLE_SKIP_OS_CHECK=true
ln -s /bin/true /usr/local/bin/service
# Run the installer in unattended mode using the preseeded variables above and --reconfigure so that local repos are not updated
curl -sSL https://install.pi-hole.net | bash -sex -- --unattended
rm /usr/local/bin/service
# IPv6 support for nc openbsd better than traditional
apt-get install -y --force-yes netcat-openbsd
# Source the Pi-hole install script to make use of the fetch_checkout_pull_branch functions as calling pihole checkout directly does not work hre
PH_TEST="true" . "${PIHOLE_INSTALL}"
[ -n "${CORE_VERSION}" ] && fetch_checkout_pull_branch ${CORE_LOCAL_REPO} "${CORE_VERSION}" && RELOAD=1
[ -n "${WEB_VERSION}" ] && fetch_checkout_pull_branch ${WEB_LOCAL_REPO} "${WEB_VERSION}" # No need to reload when checking out a new web branch
[ -n "${FTL_VERSION}" ] && echo "${FTL_VERSION}" > /etc/pihole/ftlbranch && RELOAD=1
[ -n "${RELOAD}" ] && bash -ex "${PIHOLE_INSTALL}" --unattended --reconfigure
# At this stage, if we are building a :nightly tag, then switch the Pi-hole install to dev versions
if [[ "${PIHOLE_DOCKER_TAG}" = 'nightly' ]]; then
yes | pihole checkout dev
fi
sed -i 's/readonly //g' /opt/pihole/webpage.sh
sed -i '/^WEBPASSWORD/d' /etc/pihole/setupVars.conf
# sed a new function into the `pihole` script just above the `helpFunc()` function for later use.
sed -i $'s/helpFunc() {/unsupportedFunc() {\\\n echo "Function not supported in Docker images"\\\n exit 0\\\n}\\\n\\\nhelpFunc() {/g' /usr/local/bin/pihole
# Replace a few of the `pihole` options with calls to `unsupportedFunc`:
# pihole -up / pihole updatePihole
sed -i $'s/)\s*updatePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# pihole -r / pihole reconfigure
sed -i $'s/)\s*reconfigurePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# pihole uninstall
sed -i $'s/)\s*uninstallFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# pihole -r / pihole reconfigure
sed -i $'s/)\s*reconfigurePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
if [[ "${PIHOLE_VERSION}" != "dev" && "${PIHOLE_VERSION}" != "nightly" ]]; then
# If we are on a version other than dev or nightly, disable `pihole checkout`
if [[ "${PIHOLE_DOCKER_TAG}" != "dev" && "${PIHOLE_DOCKER_TAG}" != "nightly" ]]; then
# If we are on a version other than dev or nightly, disable `pihole checkout`, otherwise it is useful to have for quick troubleshooting sometimes
sed -i $'s/)\s*piholeCheckoutFunc/) unsupportedFunc/g' /usr/local/bin/pihole
fi
# Inject a message into the debug scripts Operating System section to indicate that the debug log comes from a Docker system.
sed -i $'s/echo_current_diagnostic "Operating system"/echo_current_diagnostic "Operating system"\\\n log_write "${INFO} Pi-hole Docker Container: ${PIHOLE_VERSION:-PIHOLE_VERSION is unset}"/g' /opt/pihole/piholeDebug.sh
sed -i $'s/echo_current_diagnostic "Operating system"/echo_current_diagnostic "Operating system"\\\n log_write "${INFO} Pi-hole Docker Container: ${PIHOLE_DOCKER_TAG:-PIHOLE_DOCKER_TAG is unset}"/g' /opt/pihole/piholeDebug.sh
touch /.piholeFirstBoot

View File

@ -36,4 +36,4 @@ fi
pihole -v
echo " Container tag is: ${PIHOLE_VERSION}"
echo " Container tag is: ${PIHOLE_DOCKER_TAG}"

View File

@ -14,7 +14,7 @@ def run_and_stream_command_output():
def run_and_stream_command_output_inner(command, verbose=False):
print("Running", command)
build_env = os.environ.copy()
build_env['PIHOLE_VERSION'] = version
build_env['PIHOLE_DOCKER_TAG'] = version
build_result = subprocess.Popen(command.split(), env=build_env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
bufsize=1, universal_newlines=True)
if verbose: