Reduce Test step to only one arch (amd64/buster)

Migrate build and push step to native github actions using docker buildX - which should _hopefully_ resolve #735
Make some adjustments to Dockerfile/build.yml/install.sh to allow both gh-actions-test.sh to build using the test suite, and github actions native commands to build online

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2021-09-12 22:34:24 +01:00
parent 17453166c2
commit 7624fc3d56
No known key found for this signature in database
GPG Key ID: 872950F3ECF2B173
6 changed files with 141 additions and 163 deletions

View File

@ -1,19 +1,14 @@
232623name: Build & Deploy Nightly images
name: Build & Deploy Nightly images
on:
schedule:
- cron: '0 2 * * *'
jobs:
test-and-build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ARCH: [amd64, armhf, arm64, i386]
DEBIAN_VERSION: [buster]
env:
ARCH: ${{matrix.ARCH}}
DEBIAN_VERSION: ${{matrix.DEBIAN_VERSION}}
ARCH: amd64
DEBIAN_VERSION: buster
CORE_VERSION: development
WEB_VERSION: devel
FTL_VERSION: development
@ -22,45 +17,47 @@ jobs:
uses: actions/checkout@v2
with:
ref: dev
- name: Checkout Dummy Branch to set image name
run: |
git checkout -b nightly
- name: Run Tests
run: |
echo "Building ${ARCH}-${DEBIAN_VERSION}"
./gh-actions-test.sh
- name: Push the ARCH image
if: github.event_name != 'pull_request'
run: |
. gh-actions-vars.sh
echo "${{ secrets.DOCKERHUB_PASS }}" | docker login --username="${{ secrets.DOCKERHUB_USER }}" --password-stdin
docker push "${ARCH_IMAGE}"
- name: Upload gh-workspace
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v1
with:
name: gh-workspace
path: .gh-workspace
publish:
runs-on: ubuntu-latest
needs: test-and-build
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: dev
- name: Checkout Dummy Branch to set image name
run: |
git checkout -b nightly
- name: Download workspace files
uses: actions/download-artifact@v1
with:
name: gh-workspace
path: .gh-workspace
- name: Tag and Publish multi-arch images
env:
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
run: |
./gh-actions-deploy.sh
build-and-publish:
if: github.event_name != 'pull_request'
needs: test
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Get the tag name
run: |
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
-
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: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/i386,linux/arm/v7
build-args: |
CORE_VERSION=development
WEB_VERSION=devel
FTL_VERSION=development
PIHOLE_TAG=nightly
PIHOLE_VERSION=nightly
push: true
tags: |
${{ secrets.DOCKERHUB_USER }}/pihole:nightly

View File

@ -7,20 +7,12 @@ on:
release:
types: [published]
#env:
# DOCKER_HUB_REPO: pihole
jobs:
test-and-build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ARCH: [amd64, armhf, arm64, i386]
DEBIAN_VERSION: [buster]
env:
ARCH: ${{matrix.ARCH}}
DEBIAN_VERSION: ${{matrix.DEBIAN_VERSION}}
ARCH: amd64
DEBIAN_VERSION: buster
steps:
- name: Checkout Repo
uses: actions/checkout@v2
@ -28,34 +20,40 @@ jobs:
run: |
echo "Building ${ARCH}-${DEBIAN_VERSION}"
./gh-actions-test.sh
- name: Push the ARCH image
if: github.event_name != 'pull_request'
run: |
. gh-actions-vars.sh
echo "${{ secrets.DOCKERHUB_PASS }}" | docker login --username="${{ secrets.DOCKERHUB_USER }}" --password-stdin
docker push "${ARCH_IMAGE}"
- name: Upload gh-workspace
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v1
with:
name: gh-workspace
path: .gh-workspace
publish:
build-and-publish:
if: github.event_name != 'pull_request'
needs: test
runs-on: ubuntu-latest
needs: test-and-build
steps:
- name: Checkout Repo
-
name: Checkout
uses: actions/checkout@v2
- name: Download workspace files
uses: actions/download-artifact@v1
with:
name: gh-workspace
path: .gh-workspace
- name: Tag and Publish multi-arch images
env:
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
-
name: Get the tag name
run: |
./gh-actions-deploy.sh
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
-
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: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/i386,linux/arm/v7
build-args: |
PIHOLE_TAG=${{ env.TAG }}
PIHOLE_VERSION=${{ env.TAG }}
push: true
tags: |
${{ secrets.DOCKERHUB_USER }}/pihole:${{ env.TAG }}

View File

@ -11,25 +11,20 @@ on:
required: true
core:
description: 'Branch or tag of core repo'
required: true
required: false
web:
description: 'Branch or tag of web repo'
required: true
required: false
ftl:
description: 'Branch or tag of ftl repo'
required: true
required: false
jobs:
test-and-build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ARCH: [amd64, armhf, arm64, i386]
DEBIAN_VERSION: [buster]
env:
ARCH: ${{matrix.ARCH}}
DEBIAN_VERSION: ${{matrix.DEBIAN_VERSION}}
ARCH: amd64
DEBIAN_VERSION: buster
CORE_VERSION: ${{ github.event.inputs.core }}
WEB_VERSION: ${{ github.event.inputs.web }}
FTL_VERSION: ${{ github.event.inputs.ftl }}
@ -38,45 +33,42 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Checkout Dummy Branch to set image name
run: |
git checkout -b ${{ github.event.inputs.name }}
- name: Run Tests
run: |
echo "Building ${ARCH}-${DEBIAN_VERSION}"
./gh-actions-test.sh
- name: Push the ARCH image
if: github.event_name != 'pull_request'
run: |
. gh-actions-vars.sh
echo "${{ secrets.DOCKERHUB_PASS }}" | docker login --username="${{ secrets.DOCKERHUB_USER }}" --password-stdin
docker push "${ARCH_IMAGE}"
- name: Upload gh-workspace
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v1
with:
name: gh-workspace
path: .gh-workspace
publish:
build-and-publish:
needs: test
runs-on: ubuntu-latest
needs: test-and-build
steps:
- name: Checkout Repo
-
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:
ref: dev
- name: Checkout Dummy Branch to set image name
run: |
git checkout -b ${{ github.event.inputs.name }}
- name: Download workspace files
uses: actions/download-artifact@v1
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
name: gh-workspace
path: .gh-workspace
- name: Tag and Publish multi-arch images
env:
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
run: |
./gh-actions-deploy.sh
context: .
platforms: linux/amd64,linux/arm64,linux/i386,linux/arm/v7
build-args: |
CORE_VERSION=${{ github.event.inputs.core }}
WEB_VERSION=${{ github.event.inputs.web }}
FTL_VERSION=${{ github.event.inputs.ftl }}
PIHOLE_TAG=${{ github.event.inputs.name }}
PIHOLE_VERSION=${{ github.event.inputs.name }}
push: true
tags: |
${{ secrets.DOCKERHUB_USER }}/pihole:${{ github.event.inputs.name }}

View File

@ -1,19 +1,16 @@
ARG PIHOLE_BASE
FROM $PIHOLE_BASE
FROM "${PIHOLE_BASE:-debian:buster-slim}"
ARG PIHOLE_ARCH
ENV PIHOLE_ARCH "${PIHOLE_ARCH}"
ARG PIHOLE_TAG
ENV PIHOLE_TAG "${PIHOLE_TAG}"
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 S6_ARCH
ARG S6_VERSION
ENV S6OVERLAY_RELEASE "https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-${S6_ARCH}.tar.gz"
ARG PIHOLE_TAG
ENV PIHOLE_TAG "${PIHOLE_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
@ -28,9 +25,9 @@ COPY s6/service /usr/local/bin/service
# php config start passes special ENVs into
ARG PHP_ENV_CONFIG
ENV PHP_ENV_CONFIG "${PHP_ENV_CONFIG}"
ENV PHP_ENV_CONFIG /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
ARG PHP_ERROR_LOG
ENV PHP_ERROR_LOG "${PHP_ERROR_LOG}"
ENV PHP_ERROR_LOG /var/log/lighttpd/error.log
COPY ./start.sh /
COPY ./bash_functions.sh /
@ -53,12 +50,6 @@ ARG PIHOLE_VERSION
ENV VERSION "${PIHOLE_VERSION}"
ENV PATH /opt/pihole:${PATH}
ARG NAME
LABEL image="${NAME}:${PIHOLE_VERSION}_${PIHOLE_ARCH}"
ARG MAINTAINER
LABEL maintainer="${MAINTAINER}"
LABEL url="https://www.github.com/pi-hole/docker-pi-hole"
HEALTHCHECK CMD dig +short +norecurse +retry=0 @127.0.0.1 pi.hole || exit 1
SHELL ["/bin/bash", "-c"]
SHELL ["/bin/bash", "-c"]

View File

@ -7,12 +7,6 @@ x-common-args: &common-args
CORE_VERSION: ${CORE_VERSION}
WEB_VERSION: ${WEB_VERSION}
FTL_VERSION: ${FTL_VERSION}
NAME: pihole/pihole
MAINTAINER: adam@diginc.us
S6_VERSION: v2.1.0.2
PHP_ENV_CONFIG: /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
PHP_ERROR_LOG: /var/log/lighttpd/error.log
services:
amd64:
@ -22,8 +16,6 @@ services:
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-base:${DEBIAN_VERSION:-buster}
PIHOLE_ARCH: amd64
S6_ARCH: amd64
armel:
image: pihole:${PIHOLE_VERSION}-armel-${DEBIAN_VERSION:-buster}
build:
@ -31,8 +23,6 @@ services:
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:armel-${DEBIAN_VERSION:-buster}-slim
PIHOLE_ARCH: armel
S6_ARCH: arm
armhf:
image: pihole:${PIHOLE_VERSION}-armhf-${DEBIAN_VERSION:-buster}
build:
@ -40,8 +30,6 @@ services:
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:armhf-${DEBIAN_VERSION:-buster}-slim
PIHOLE_ARCH: arm
S6_ARCH: arm
arm64:
image: pihole:${PIHOLE_VERSION}-arm64-${DEBIAN_VERSION:-buster}
build:
@ -49,14 +37,10 @@ services:
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:arm64-${DEBIAN_VERSION:-buster}-slim
PIHOLE_ARCH: arm64
S6_ARCH: aarch64
i386:
image: pihole:${PIHOLE_VERSION}-i386-${DEBIAN_VERSION:-buster}
build:
context: .
args:
<<: *common-args
PIHOLE_BASE: pihole/debian-debootstrap:i386-${DEBIAN_VERSION:-buster}-slim
PIHOLE_ARCH: i386
S6_ARCH: x86
PIHOLE_BASE: pihole/debian-debootstrap:i386-${DEBIAN_VERSION:-buster}-slim

View File

@ -8,13 +8,29 @@ WEB_LOCAL_REPO=/var/www/html/admin
setupVars=/etc/pihole/setupVars.conf
s6_download_url() {
DETECTED_ARCH=$(dpkg --print-architecture)
S6_ARCH=$DETECTED_ARCH
case $DETECTED_ARCH in
armel)
S6_ARCH="arm";;
armhf)
S6_ARCH="arm";;
arm64)
S6_ARCH="aarch64";;
i386)
S6_ARCH="x86";;
esac
echo "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.gz"
}
apt-get update
apt-get install --no-install-recommends -y curl procps ca-certificates git
# curl in armhf-buster's image has SSL issues. Running c_rehash fixes it.
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923479
c_rehash
ln -s `which echo` /usr/local/bin/whiptail
curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C /
curl -L -s "$(s6_download_url)" | tar xvzf - -C /
mv /init /s6-init
# Preseed variables to assist with using --unattended install
@ -71,9 +87,9 @@ sed -i $'s/)\s*uninstallFunc/) unsupportedFunc/g' /usr/local/bin/pihole
sed -i $'s/echo_current_diagnostic "Operating system"/echo_current_diagnostic "Operating system"\\\n log_write "${INFO} Pi-hole Docker Container: ${PIHOLE_TAG:-PIHOLE_TAG is unset}"/g' /opt/pihole/piholeDebug.sh
# Inject container tag into web interface footer...
sed -i $"s/<ul class=\"list-unstyled\">/<ul class=\"list-unstyled\">\\n<strong><li>Docker Tag<\/strong> ${PIHOLE_TAG//\//\\/}<\/li>/g" /var/www/html/admin/scripts/pi-hole/php/footer.php
sed -i $"s/<ul class=\"list-inline\">/<strong>Docker Tag<\/strong> ${PIHOLE_TAG//\//\\/}\\n<ul class=\"list-inline\">/g" /var/www/html/admin/scripts/pi-hole/php/footer.php
sed -i $"s/<ul class=\"list-unstyled\">/<ul class=\"list-unstyled\">\\n<strong><li>Docker Tag<\/strong> ${PIHOLE_TAG}<\/li>/g" /var/www/html/admin/scripts/pi-hole/php/footer.php
sed -i $"s/<ul class=\"list-inline\">/<strong>Docker Tag<\/strong> ${PIHOLE_TAG}\\n<ul class=\"list-inline\">/g" /var/www/html/admin/scripts/pi-hole/php/footer.php
touch /.piholeFirstBoot
echo 'Docker install successful'
echo 'Docker install successful'