From 60bd77f5867ccb3b0d549cef29a97accf2d80780 Mon Sep 17 00:00:00 2001 From: diginc Date: Sat, 30 Jun 2018 17:16:16 -0500 Subject: [PATCH 01/39] Add in install option for FTLDNS --- Dockerfile.py | 3 +- Dockerfile.template | 8 +++--- Dockerfile_debian_aarch64 | 10 +++---- Dockerfile_debian_amd64 | 10 +++---- Dockerfile_debian_armhf | 10 +++---- deploy_arm.sh | 4 +-- install.sh | 59 +++++++++++++++++++++++++-------------- 7 files changed, 61 insertions(+), 43 deletions(-) diff --git a/Dockerfile.py b/Dockerfile.py index ea56ccc..8c891ec 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -27,7 +27,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__)) base_vars = { 'name': 'diginc/pi-hole', 'maintainer' : 'adam@diginc.us', - 's6_version' : 'v1.21.2.2', + 's6_version' : 'v1.21.4.0', } os_base_vars = { @@ -111,6 +111,7 @@ def build(docker_repo, os, arch, args): build_result = run_local(build_command) if args['-v']: print build_result.stdout + print build_result.stderr if build_result.rc != 0: print " ::: Building {} encountered an error".format(dockerfile) print build_result.stderr diff --git a/Dockerfile.template b/Dockerfile.template index ba90181..3f2d908 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -14,13 +14,13 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ pihole.s6_version }}/s6-overlay-{{ pihole.arch }}.tar.gz RUN apt-get update && \ - apt-get install -y wget curl net-tools cron procps && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ + apt-get install -y curl && \ + curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init +RUN apt-get update && bash -ex docker-install.sh 2>&1 + ENTRYPOINT [ "/s6-init" ] ADD s6/{{ pihole.os }}-root / diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index 0907fb7..4c1066e 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -11,16 +11,16 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.2/s6-overlay-aarch64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-aarch64.tar.gz RUN apt-get update && \ - apt-get install -y wget curl net-tools cron procps && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ + apt-get install -y curl && \ + curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init +RUN apt-get update && bash -ex docker-install.sh 2>&1 + ENTRYPOINT [ "/s6-init" ] ADD s6/debian-root / diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index 5d625ca..2376e14 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -11,16 +11,16 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.2/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-amd64.tar.gz RUN apt-get update && \ - apt-get install -y wget curl net-tools cron procps && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ + apt-get install -y curl && \ + curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init +RUN apt-get update && bash -ex docker-install.sh 2>&1 + ENTRYPOINT [ "/s6-init" ] ADD s6/debian-root / diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index 132d32b..fa4d311 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -11,16 +11,16 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.2/s6-overlay-armhf.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-armhf.tar.gz RUN apt-get update && \ - apt-get install -y wget curl net-tools cron procps && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ + apt-get install -y curl && \ + curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init +RUN apt-get update && bash -ex docker-install.sh 2>&1 + ENTRYPOINT [ "/s6-init" ] ADD s6/debian-root / diff --git a/deploy_arm.sh b/deploy_arm.sh index a4d9f27..8afe2f7 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -ex # Script for manually pushing the docker arm images for diginc only # (no one else has docker repo permissions) if [ ! -f ~/.docker/config.json ] ; then @@ -7,7 +7,7 @@ if [ ! -f ~/.docker/config.json ] ; then fi if [[ "$1" == 'prod' ]] ; then - export version='3.3' + export version="${latest}" for tag in debian_armhf debian_aarch64; do # Verison specific tags for ongoing history docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:v${version}_${tag} diff --git a/install.sh b/install.sh index 8fbf6dd..08e4384 100755 --- a/install.sh +++ b/install.sh @@ -4,10 +4,12 @@ mkdir -p /var/run/pihole export CORE_TAG='v3.3.1' export WEB_TAG='v3.3' export FTL_TAG='v3.0' +export USE_FTLDNS_BRANCHES=true export USE_DEVELOPMENT_BRANCHES=false -if [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then - # install from custom hash or branch +if [[ $USE_FTLDNS_BRANCHES == true ]] ; then + CORE_TAG='FTLDNS' +elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then CORE_TAG='development' fi @@ -19,20 +21,36 @@ which systemctl && mv "$(which systemctl)" /bin/no_systemctl which debconf-apt-progress && mv "$(which debconf-apt-progress)" /bin/no_debconf-apt-progress # Get the install functions -wget -O "$PIHOLE_INSTALL" https://raw.githubusercontent.com/pi-hole/pi-hole/${CORE_TAG}/automated%20install/basic-install.sh +curl https://raw.githubusercontent.com/pi-hole/pi-hole/${CORE_TAG}/automated%20install/basic-install.sh > "$PIHOLE_INSTALL" PH_TEST=true . "${PIHOLE_INSTALL}" -# Run only what we need from installer +# Preseed variables to assist with using --unattended install +{ + echo "PIHOLE_INTERFACE=eth0" + echo "IPV4_ADDRESS=0.0.0.0" + echo "IPV6_ADDRESS=0:0:0:0:0:0" + echo "PIHOLE_DNS_1=8.8.8.8" + echo "PIHOLE_DNS_2=8.8.4.4" + echo "QUERY_LOGGING=true" + echo "INSTALL_WEB_SERVER=true" + echo "INSTALL_WEB_INTERFACE=true" + echo "LIGHTTPD_ENABLED=true" +}>> "${setupVars}" +source $setupVars + export USER=pihole -if [[ "$TAG" == 'debian' ]] ; then - distro_check - install_dependent_packages INSTALLER_DEPS[@] - install_dependent_packages PIHOLE_DEPS[@] - install_dependent_packages PIHOLE_WEB_DEPS[@] - sed -i "/sleep 2/ d" /etc/init.d/dnsmasq # SLOW - # IPv6 support for nc openbsd better than traditional - apt-get install -y --force-yes netcat-openbsd -fi +distro_check + +# fix permission denied to resolvconf post-inst /etc/resolv.conf moby/moby issue #1297 +apt-get -y install debconf-utils && echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections + +# Tried this - unattended causes starting services during a build, should probably PR a flag to shut that off and switch to that +#bash -ex "./${PIHOLE_INSTALL}" --unattended +install_dependent_packages INSTALLER_DEPS[@] +install_dependent_packages PIHOLE_DEPS[@] +install_dependent_packages PIHOLE_WEB_DEPS[@] +# IPv6 support for nc openbsd better than traditional +apt-get install -y --force-yes netcat-openbsd piholeGitUrl="${piholeGitUrl}" webInterfaceGitUrl="${webInterfaceGitUrl}" @@ -40,19 +58,18 @@ webInterfaceDir="${webInterfaceDir}" git clone "${piholeGitUrl}" "${PI_HOLE_LOCAL_REPO}" git clone "${webInterfaceGitUrl}" "${webInterfaceDir}" -export PIHOLE_INTERFACE=eth0 -export IPV4_ADDRESS=0.0.0.0 -export IPV6_ADDRESS=0:0:0:0:0:0 -export PIHOLE_DNS_1=8.8.8.8 -export PIHOLE_DNS_2=8.8.4.4 -export QUERY_LOGGING=true - tmpLog="/tmp/pihole-install.log" installLogLoc="${installLogLoc}" installPihole | tee "${tmpLog}" mv "${tmpLog}" / -if [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then +if [[ $USE_FTLDNS_BRANCHES == true ]] ; then + ln -s /bin/true /usr/local/bin/service + echo "FTLDNS" | tee /etc/pihole/ftlbranch + echo y | bash -x pihole checkout core FTLDNS + echo y | bash -x pihole checkout web FTLDNS + unlink /usr/local/bin/service +elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then ln -s /bin/true /usr/local/bin/service echo y | bash -x pihole checkout core development echo y | bash -x pihole checkout web devel From d45bccf9b4a125779bf122243848764554019737 Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 2 Jul 2018 20:50:31 -0500 Subject: [PATCH 02/39] remove dnsmasq service for new pihole-FTL service --- s6/debian-root/etc/services.d/dnsmasq/finish | 3 --- s6/debian-root/etc/services.d/dnsmasq/run | 5 ----- 2 files changed, 8 deletions(-) delete mode 100644 s6/debian-root/etc/services.d/dnsmasq/finish delete mode 100644 s6/debian-root/etc/services.d/dnsmasq/run diff --git a/s6/debian-root/etc/services.d/dnsmasq/finish b/s6/debian-root/etc/services.d/dnsmasq/finish deleted file mode 100644 index 77aec95..0000000 --- a/s6/debian-root/etc/services.d/dnsmasq/finish +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash - -kill -9 $(pgrep dnsmasq) diff --git a/s6/debian-root/etc/services.d/dnsmasq/run b/s6/debian-root/etc/services.d/dnsmasq/run deleted file mode 100644 index 7a19a39..0000000 --- a/s6/debian-root/etc/services.d/dnsmasq/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/with-contenv bash - -s6-echo "Starting dnsmasq" - -s6-setuidgid root dnsmasq -7 /etc/dnsmasq.d --no-daemon From ad6b4be40343a9b9c36ee0942bfb5ffd7b5e346e Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 3 Jul 2018 00:19:01 -0500 Subject: [PATCH 03/39] Fixes to the startup, services, and dnsmasq references --- Dockerfile.template | 2 +- Dockerfile_debian_aarch64 | 2 +- Dockerfile_debian_amd64 | 2 +- Dockerfile_debian_armhf | 2 +- bash_functions.sh | 3 +-- s6/debian-root/etc/cont-init.d/20-start.sh | 4 ++-- s6/debian-root/etc/services.d/pihole-FTL/run | 3 ++- test/conftest.py | 4 ++-- test/test_pihole_scripts.py | 12 ++++++------ 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 3f2d908..364202d 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -14,7 +14,7 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ pihole.s6_version }}/s6-overlay-{{ pihole.arch }}.tar.gz RUN apt-get update && \ - apt-get install -y curl && \ + apt-get install -y curl procps && \ curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index 4c1066e..90561a7 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -14,7 +14,7 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-aarch64.tar.gz RUN apt-get update && \ - apt-get install -y curl && \ + apt-get install -y curl procps && \ curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index 2376e14..fa09f7c 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -14,7 +14,7 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-amd64.tar.gz RUN apt-get update && \ - apt-get install -y curl && \ + apt-get install -y curl procps && \ curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index fa4d311..a5f7e28 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -14,7 +14,7 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-armhf.tar.gz RUN apt-get update && \ - apt-get install -y curl && \ + apt-get install -y curl procps && \ curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init diff --git a/bash_functions.sh b/bash_functions.sh index 1e9d16c..9ecdd3e 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -90,7 +90,6 @@ setup_dnsmasq() { setup_dnsmasq_dns "$DNS1" "$DNS2" setup_dnsmasq_interface "$INTERFACE" ProcessDNSSettings - # dnsmasq -7 /etc/dnsmasq.d --interface="${INTERFACE:-eth0}" } setup_dnsmasq_hostnames() { @@ -228,7 +227,7 @@ test_configs() { test_configs_debian() { set -e echo -n '::: Testing DNSmasq config: ' - dnsmasq --test -7 /etc/dnsmasq.d || exit 1 + pihole-FTL --test -7 /etc/dnsmasq.d || exit 1 echo -n '::: Testing lighttpd config: ' lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1 set +e diff --git a/s6/debian-root/etc/cont-init.d/20-start.sh b/s6/debian-root/etc/cont-init.d/20-start.sh index e1a1f9b..d39887e 100644 --- a/s6/debian-root/etc/cont-init.d/20-start.sh +++ b/s6/debian-root/etc/cont-init.d/20-start.sh @@ -8,10 +8,10 @@ if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then fi # Start dnsmasq for validate_env and gravity.sh -dnsmasq -7 /etc/dnsmasq.d +pihole-FTL $bashCmd /start.sh gravity.sh # Kill dnsmasq because s6 won't like it if it's running when s6 services start -kill -9 $(pgrep dnsmasq) || true +kill -9 $(pgrep pihole-FTL) || true diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 0d52ace..98e9cba 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -1,4 +1,5 @@ #!/usr/bin/with-contenv bash s6-echo "Starting pihole-FTL ($FTL_CMD)" -pihole-FTL ${FTL_CMD} +s6-setuidgid root pihole-FTL $FTL_CMD + diff --git a/test/conftest.py b/test/conftest.py index f122a65..3b23449 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -86,7 +86,7 @@ def cmd(request): @pytest.fixture(scope='module', params=['amd64']) def persist_arch(request): - '''amd64 only, dnsmasq will not start under qemu-user-static :(''' + '''amd64 only, dnsmasq/pihole-FTL(?untested?) will not start under qemu-user-static :(''' return request.param @pytest.fixture(scope='module', params=['debian']) @@ -157,6 +157,6 @@ Persistent Docker container for testing service post start.sh @pytest.fixture def RunningPiHole(DockerPersist, Slow, persist_webserver): ''' Persist a fully started docker-pi-hole to help speed up subsequent tests ''' - Slow(lambda: DockerPersist.run('pgrep dnsmasq').rc == 0) + Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0) Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver) ).rc == 0) return DockerPersist diff --git a/test/test_pihole_scripts.py b/test/test_pihole_scripts.py index 66cd032..bb6b877 100644 --- a/test/test_pihole_scripts.py +++ b/test/test_pihole_scripts.py @@ -8,18 +8,18 @@ def start_cmd(): @pytest.fixture def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd): ''' Override the RunningPiHole to run and check for success of a - dnsmasq start based `pihole` script command ''' + pihole-FTL start based `pihole` script command ''' #print DockerPersist.run('ps -ef').stdout assert DockerPersist.dig.run('ping -c 1 test_pihole').rc == 0 - Slow(lambda: DockerPersist.run('pgrep dnsmasq').rc == 0) + Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0) Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver)).rc == 0) - oldpid = DockerPersist.run('pidof dnsmasq') + oldpid = DockerPersist.run('pidof pihole-FTL') cmd = DockerPersist.run('pihole {}'.format(start_cmd)) - Slow(lambda: DockerPersist.run('pgrep dnsmasq').rc == 0) - newpid = DockerPersist.run('pidof dnsmasq') + Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0) + newpid = DockerPersist.run('pidof pihole-FTL') for pid in [oldpid, newpid]: assert pid != '' - # ensure a new pid for dnsmasq appeared due to service restart + # ensure a new pid for pihole-FTL appeared due to service restart assert oldpid != newpid assert cmd.rc == 0 # Save out cmd result to check different stdout of start/enable/disable From 3877a171da64bb2b61b5007f46ac3a7f8f04a248 Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 4 Jul 2018 14:11:18 -0500 Subject: [PATCH 04/39] fix startup 53 port conflict and test error --- bash_functions.sh | 4 ++-- s6/debian-root/etc/cont-init.d/20-start.sh | 3 +-- test/test_bash_functions.py | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 9ecdd3e..710ae42 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -226,8 +226,8 @@ test_configs() { test_configs_debian() { set -e - echo -n '::: Testing DNSmasq config: ' - pihole-FTL --test -7 /etc/dnsmasq.d || exit 1 + echo -n '::: Testing pihole-FTL DNS: ' + pihole-FTL test || exit 1 echo -n '::: Testing lighttpd config: ' lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1 set +e diff --git a/s6/debian-root/etc/cont-init.d/20-start.sh b/s6/debian-root/etc/cont-init.d/20-start.sh index d39887e..e82dda3 100644 --- a/s6/debian-root/etc/cont-init.d/20-start.sh +++ b/s6/debian-root/etc/cont-init.d/20-start.sh @@ -7,8 +7,7 @@ if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then bashCmd='bash -e -x' fi -# Start dnsmasq for validate_env and gravity.sh -pihole-FTL +# used to start dnsmasq here for gravity to use...now that conflicts port 53 $bashCmd /start.sh gravity.sh diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index a9fa2b7..a35776a 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -131,7 +131,9 @@ def test_debian_setup_php_env(Docker, os, expected_lines, repeat_function): for expected_line in expected_lines: search_config_cmd = "grep -c '{}' /etc/lighttpd/conf-enabled/15-fastcgi-php.conf".format(expected_line) search_config_count = Docker.run(search_config_cmd) - assert search_config_count.stdout.rstrip('\n') == '1' + found_lines = int(search_config_count.stdout.rstrip('\n')) + if found_lines > 1: + assert False, "Found line {} times (more than once): {}".format(searexpected_line) @pytest.mark.parametrize('args,secure,setupVarsHash', [ ('-e ServerIP=1.2.3.4 -e WEBPASSWORD=login', True, 'WEBPASSWORD=6060d59351e8c2f48140f01b2c3f3b61652f396c53a5300ae239ebfbe7d5ff08'), From bb3885a15beb40164463b13ed465060f26616825 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 12 Jul 2018 11:34:47 -0500 Subject: [PATCH 05/39] Update the deploy arm to work...better --- deploy_arm.sh | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/deploy_arm.sh b/deploy_arm.sh index 8afe2f7..12658d5 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -1,4 +1,4 @@ -#!/bin/bash -ex +#!/bin/bash -e # Script for manually pushing the docker arm images for diginc only # (no one else has docker repo permissions) if [ ! -f ~/.docker/config.json ] ; then @@ -6,20 +6,41 @@ if [ ! -f ~/.docker/config.json ] ; then exit 1 fi -if [[ "$1" == 'prod' ]] ; then - export version="${latest}" + +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} + +branch="$(parse_git_branch)" +version="${version:-unset}" +dry="${dry}" + +if [[ -n "$dry" ]] ; then dry='echo ' ; fi + +if [[ "$version" == 'unset' && "$branch" == 'master' ]]; then + echo "Version is unset and master/prod branch wants a version...pass in \$version!" + exit 1 +fi + +echo "# DEPLOYING:\n" +echo "version: $version" +echo "branch: $branch" +[[ -n "$dry" ]] && echo "DRY RUN: $dry" + +$dry ./Dockerfile.py + +if [[ "$branch" == 'master' ]] ; then for tag in debian_armhf debian_aarch64; do # Verison specific tags for ongoing history - docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:v${version}_${tag} - docker push diginc/pi-hole-multiarch:v${version}_${tag} + $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:v${version}_${tag} + $dry docker push diginc/pi-hole-multiarch:v${version}_${tag} # Floating latest tags - docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag} - docker push diginc/pi-hole-multiarch:${tag} + $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag} + $dry docker push diginc/pi-hole-multiarch:${tag} done -elif [[ "$1" == 'dev' ]] ; then +else for tag in debian_armhf debian_aarch64; do - # Floating dev tag - docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag}_dev - docker push diginc/pi-hole-multiarch:${tag}_dev + $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag}_${branch} + $dry docker push diginc/pi-hole-multiarch:${tag}_${branch} done fi From e56b5eda0012ad09154186be288f017a0de35d5e Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 12 Jul 2018 11:36:36 -0500 Subject: [PATCH 06/39] small tweak to deploy_arm --- deploy_arm.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deploy_arm.sh b/deploy_arm.sh index 12658d5..1ad6db3 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -ex # Script for manually pushing the docker arm images for diginc only # (no one else has docker repo permissions) if [ ! -f ~/.docker/config.json ] ; then @@ -22,10 +22,11 @@ if [[ "$version" == 'unset' && "$branch" == 'master' ]]; then exit 1 fi -echo "# DEPLOYING:\n" +echo "# DEPLOYING:" echo "version: $version" echo "branch: $branch" [[ -n "$dry" ]] && echo "DRY RUN: $dry" +echo $dry ./Dockerfile.py From 520669a6b9ec180dd91a4959a66a2ff0eba242a8 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 19 Jul 2018 22:18:34 -0500 Subject: [PATCH 07/39] merge in dev/master armel goodies --- test/test_bash_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index c744fc3..b2e5c6f 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -135,7 +135,7 @@ def test_debian_setup_php_env(Docker, os, expected_lines, repeat_function): search_config_count = Docker.run(search_config_cmd) found_lines = int(search_config_count.stdout.rstrip('\n')) if found_lines > 1: - assert False, "Found line {} times (more than once): {}".format(searexpected_line) + assert False, "Found line {} times (more than once): {}".format(expected_line) @pytest.mark.parametrize('args,secure,setupVarsHash', [ ('-e ServerIP=1.2.3.4 -e WEBPASSWORD=login', True, 'WEBPASSWORD=6060d59351e8c2f48140f01b2c3f3b61652f396c53a5300ae239ebfbe7d5ff08'), From 0e7ab463fae69cf71331becd315de4767d7d6f10 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 19 Jul 2018 22:56:59 -0500 Subject: [PATCH 08/39] add finish scripts to restart cleanly Signed-off-by: Adam Hill --- s6/debian-root/etc/services.d/cron/finish | 4 ++++ s6/debian-root/etc/services.d/lighttpd/finish | 4 ++++ s6/debian-root/etc/services.d/lighttpd/run | 1 - s6/debian-root/etc/services.d/pihole-FTL/finish | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 s6/debian-root/etc/services.d/cron/finish create mode 100644 s6/debian-root/etc/services.d/lighttpd/finish create mode 100644 s6/debian-root/etc/services.d/pihole-FTL/finish diff --git a/s6/debian-root/etc/services.d/cron/finish b/s6/debian-root/etc/services.d/cron/finish new file mode 100644 index 0000000..7d31867 --- /dev/null +++ b/s6/debian-root/etc/services.d/cron/finish @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +s6-echo "Stopping cron" +killall -9 cron diff --git a/s6/debian-root/etc/services.d/lighttpd/finish b/s6/debian-root/etc/services.d/lighttpd/finish new file mode 100644 index 0000000..af286cf --- /dev/null +++ b/s6/debian-root/etc/services.d/lighttpd/finish @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +s6-echo "Stopping lighttpd" +killall -9 lighttpd diff --git a/s6/debian-root/etc/services.d/lighttpd/run b/s6/debian-root/etc/services.d/lighttpd/run index 20a1809..a9b2bf6 100644 --- a/s6/debian-root/etc/services.d/lighttpd/run +++ b/s6/debian-root/etc/services.d/lighttpd/run @@ -1,5 +1,4 @@ #!/usr/bin/with-contenv bash s6-echo "Starting lighttpd" - lighttpd -D -f /etc/lighttpd/lighttpd.conf diff --git a/s6/debian-root/etc/services.d/pihole-FTL/finish b/s6/debian-root/etc/services.d/pihole-FTL/finish new file mode 100644 index 0000000..81bd65f --- /dev/null +++ b/s6/debian-root/etc/services.d/pihole-FTL/finish @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +s6-echo "Stopping pihole-FTL" +/etc/init.d/pihole-FTL stop From 468470b7b5f90b49f7ce61b81870a36561158497 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 29 Jul 2018 18:14:24 -0500 Subject: [PATCH 09/39] Added setup_blocklists, other cleanup * Removed some old switch statements from alpine no longer required * Limit parallel tests to 2 to help prevent test failure caused by race condition starting parallel tests/containers * Began introducing a new ENV NO_SETUP to skip the majority of startup script 'setup' functions eventually Signed-off-by: Adam Hill --- .travis.yml | 3 +- Dockerfile.template | 3 +- Dockerfile_debian_aarch64 | 3 +- Dockerfile_debian_amd64 | 3 +- Dockerfile_debian_armel | 11 ++-- Dockerfile_debian_armhf | 3 +- bash_functions.sh | 104 +++++++++++++++++++++++--------------- start.sh | 14 +++-- tox.ini | 9 ++-- 9 files changed, 91 insertions(+), 62 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6cfc7c1..2c65e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,4 +21,5 @@ script: - ./Dockerfile.py --arch=${ARCH} -v - docker images # run docker build & tests - - py.test -vv -n auto -k "${ARCH}" ./test/ + # 2 parallel max b/c race condition with docker fixture (I think?) + - py.test -vv -n 2 -k "${ARCH}" ./test/ diff --git a/Dockerfile.template b/Dockerfile.template index afdef43..43253de 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -9,8 +9,7 @@ ENV ARCH {{ pihole.arch }} ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh -ENV setupVars /etc/pihole/setupVars.conf -ENV PIHOLE_INSTALL /tmp/ph_install.sh +ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ pihole.s6_version }}/s6-overlay-{{ pihole.s6arch }}.tar.gz RUN apt-get update && \ diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index a88fa5f..ed63b32 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -9,8 +9,7 @@ ENV ARCH aarch64 ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh -ENV setupVars /etc/pihole/setupVars.conf -ENV PIHOLE_INSTALL /tmp/ph_install.sh +ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-aarch64.tar.gz RUN apt-get update && \ diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index c38b9b2..77628ec 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -9,8 +9,7 @@ ENV ARCH amd64 ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh -ENV setupVars /etc/pihole/setupVars.conf -ENV PIHOLE_INSTALL /tmp/ph_install.sh +ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-amd64.tar.gz RUN apt-get update && \ diff --git a/Dockerfile_debian_armel b/Dockerfile_debian_armel index a96851b..17425d1 100644 --- a/Dockerfile_debian_armel +++ b/Dockerfile_debian_armel @@ -9,18 +9,17 @@ ENV ARCH armel ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh -ENV setupVars /etc/pihole/setupVars.conf -ENV PIHOLE_INSTALL /tmp/ph_install.sh +ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-arm.tar.gz RUN apt-get update && \ - apt-get install -y wget curl net-tools cron procps && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ + apt-get install -y curl procps && \ + curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C / && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* && \ mv /init /s6-init +RUN apt-get update && bash -ex docker-install.sh 2>&1 + ENTRYPOINT [ "/s6-init" ] ADD s6/debian-root / diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index 4c77ba8..f56b532 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -9,8 +9,7 @@ ENV ARCH armhf ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh -ENV setupVars /etc/pihole/setupVars.conf -ENV PIHOLE_INSTALL /tmp/ph_install.sh +ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-armhf.tar.gz RUN apt-get update && \ diff --git a/bash_functions.sh b/bash_functions.sh index 14a05e3..8acf059 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -1,9 +1,4 @@ #!/bin/bash -. /opt/pihole/webpage.sh -setupVars="$setupVars" -ServerIP="$ServerIP" -ServerIPv6="$ServerIPv6" -IPv6="$IPv6" prepare_setup_vars() { touch "$setupVars" @@ -72,13 +67,13 @@ setup_dnsmasq_dns() { } setup_dnsmasq_interface() { - local INTERFACE="${1:-eth0}" + local interface="${1:-eth0}" local interfaceType='default' - if [ "$INTERFACE" != 'eth0' ] ; then + if [ "$interface" != 'eth0' ] ; then interfaceType='custom' fi; - echo "DNSMasq binding to $interfaceType interface: $INTERFACE" - [ -n "$INTERFACE" ] && change_setting "PIHOLE_INTERFACE" "${INTERFACE}" + echo "DNSMasq binding to $interfaceType interface: $interface" + [ -n "$interface" ] && change_setting "PIHOLE_INTERFACE" "${interface}" } setup_dnsmasq_config_if_missing() { @@ -89,10 +84,13 @@ setup_dnsmasq_config_if_missing() { } setup_dnsmasq() { + local dns1="$1" + local dns2="$2" + local interface="$3" # Coordinates setup_dnsmasq_config_if_missing - setup_dnsmasq_dns "$DNS1" "$DNS2" - setup_dnsmasq_interface "$INTERFACE" + setup_dnsmasq_dns "$dns1" "$dns2" + setup_dnsmasq_interface "$interface" ProcessDNSSettings } @@ -134,23 +132,16 @@ setup_dnsmasq_hostnames() { } setup_lighttpd_bind() { - if [[ "$TAG" == 'debian' ]] ; then + local serverip="$1" # if using '--net=host' only bind lighttpd on $ServerIP and localhost - if grep -q "docker" /proc/net/dev ; then #docker (docker0 by default) should only be present on the host system - if ! grep -q "server.bind" /etc/lighttpd/lighttpd.conf ; then # if the declaration is already there, don't add it again - sed -i -E "s/server\.port\s+\=\s+([0-9]+)/server.bind\t\t = \"${ServerIP}\"\nserver.port\t\t = \1\n"\$SERVER"\[\"socket\"\] == \"127\.0\.0\.1:\1\" \{\}/" /etc/lighttpd/lighttpd.conf - fi + if grep -q "docker" /proc/net/dev ; then #docker (docker0 by default) should only be present on the host system + if ! grep -q "server.bind" /etc/lighttpd/lighttpd.conf ; then # if the declaration is already there, don't add it again + sed -i -E "s/server\.port\s+\=\s+([0-9]+)/server.bind\t\t = \"${serverip}\"\nserver.port\t\t = \1\n"\$SERVER"\[\"socket\"\] == \"127\.0\.0\.1:\1\" \{\}/" /etc/lighttpd/lighttpd.conf fi fi } setup_php_env() { - case $TAG in - "debian") setup_php_env_debian ;; - esac -} - -setup_php_env_debian() { if [ -z "$VIRTUAL_HOST" ] ; then VIRTUAL_HOST="$ServerIP" fi; @@ -202,48 +193,81 @@ setup_web_password() { WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) echo "Assigning random password: $WEBPASSWORD" fi; + # Turn bash debug on while setting up password (to print it) set -x if [[ "$WEBPASSWORD" == "" ]] ; then echo "" | pihole -a -p else pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" fi - { set +x; } 2>/dev/null + if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then + # Turn bash debug back off after print password setup + # (subshell to null hides printing output) + { set +x; } 2>/dev/null + fi } setup_ipv4_ipv6() { local ip_versions="IPv4 and IPv6" if [ "$IPv6" != "True" ] ; then ip_versions="IPv4" - case $TAG in - "debian") sed -i '/use-ipv6.pl/ d' /etc/lighttpd/lighttpd.conf ;; - esac + sed -i '/use-ipv6.pl/ d' /etc/lighttpd/lighttpd.conf fi; echo "Using $ip_versions" } test_configs() { - case $TAG in - "debian") test_configs_debian ;; - esac -} - -test_configs_debian() { set -e echo -n '::: Testing pihole-FTL DNS: ' pihole-FTL test || exit 1 echo -n '::: Testing lighttpd config: ' lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1 set +e - echo "::: All config checks passed, starting ..." + echo "::: All config checks passed, cleared for startup ..." } -test_framework_stubbing() { - if [ -n "$PYTEST" ] ; then - echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block" - sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" - echo '123.123.123.123 testblock.pi-hole.local' > /var/www/html/fake.list - echo 'file:///var/www/html/fake.list' > /etc/pihole/adlists.list - echo 'http://localhost/fake.list' >> /etc/pihole/adlists.list + +setup_blocklists() { + local blocklists="$1" + # Exit/return early without setting up adlists with defaults for any of the following conditions: + # 1. NO_SETUP env is set + exit_string="(exiting ${FUNCNAME[0]} early)" + + if [ -n "${NO_SETUP}" ]; then + echo "::: NO_SETUP requested ($exit_string)" + return fi + + # 2. The adlist file exists already (restarted container or volume mounted list) + if [ -f "${adlistFile}" ]; then + echo "::: Preexisting ad list ${adlistFile} detected ($exit_string)" + cat "${adlistFile}" + return + fi + + # 3. If we're running tests, use a small list of fake tests to speed everything up + if [ -n "$PYTEST" ]; then + echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block ${exit_string}" + sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" + echo '123.123.123.123 testblock.pi-hole.local' > "/var/www/html/fake.list" + echo 'file:///var/www/html/fake.list' > "${adlistFile}" + echo 'http://localhost/fake.list' >> "${adlistFile}" + return + fi + + echo "::: ${FUNCNAME[0]} now setting default blocklists up: " + echo "::: TIP: Use a docker volume for ${adlistFile} if you want to customize for first boot" + > "${adlistFile}" + # Just copied outa the choices for now + # https://github.com/pi-hole/pi-hole/blob/FTLDNS/automated%20install/basic-install.sh#L1014 + echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >> "${adlistFile}" + echo "https://mirror1.malwaredomains.com/files/justdomains" >> "${adlistFile}" + echo "http://sysctl.org/cameleon/hosts" >> "${adlistFile}" + echo "https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist" >> "${adlistFile}" + echo "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt" >> "${adlistFile}" + echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}" + echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}" + + echo "::: Blocklists (${adlistFile}) now set to:" + cat "${adlistFile}" } diff --git a/start.sh b/start.sh index 89b9ad6..9f5e3d5 100755 --- a/start.sh +++ b/start.sh @@ -15,8 +15,16 @@ export IPv6 export WEBPASSWORD export WEB_PORT +export adlistFile='/etc/pihole/adlists.list' + +# The below functions are all contained in bash_functions.sh . /bash_functions.sh +# Some of the bash_functions use variables these core pi-hole/web scripts +. /opt/pihole/webpage.sh +# PH_TEST prevents the install from actually running (someone should rename that) +PH_TEST=true . $PIHOLE_INSTALL + echo " ::: Starting docker specific setup for docker diginc/pi-hole" validate_env || exit 1 prepare_setup_vars @@ -24,13 +32,13 @@ change_setting "IPV4_ADDRESS" "$ServerIP" change_setting "IPV6_ADDRESS" "$ServerIPv6" setup_web_port "$WEB_PORT" setup_web_password "$WEBPASSWORD" -setup_dnsmasq "$DNS1" "$DNS2" +setup_dnsmasq "$DNS1" "$DNS2" "$INTERFACE" setup_php_env setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME" setup_ipv4_ipv6 -setup_lighttpd_bind "$ServerIP" "$TAG" +setup_lighttpd_bind "$ServerIP" +setup_blocklists test_configs -test_framework_stubbing [ -f /.piholeFirstBoot ] && rm /.piholeFirstBoot diff --git a/tox.ini b/tox.ini index 4fb58a5..54ab13d 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,11 @@ envlist = py27 [testenv] whitelist_externals = docker deps = -rrequirements.txt +# 2 parallel max b/c race condition with docker fixture (I think?) commands = docker run --rm --privileged multiarch/qemu-user-static:register --reset ./Dockerfile.py -v --arch amd64 - pytest -vv -n auto -k amd64 ./test/ + pytest -vv -n 2 -k amd64 ./test/ ./Dockerfile.py -v --skip amd64 - pytest -vv -n auto -k armel ./test/ - pytest -vv -n auto -k armhf ./test/ - pytest -vv -n auto -k aarch64 ./test/ + pytest -vv -n 2 -k armel ./test/ + pytest -vv -n 2 -k armhf ./test/ + pytest -vv -n 2 -k aarch64 ./test/ From c7d775a82a410b31afd54120a92c44ac03c15e9a Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Mon, 30 Jul 2018 22:29:36 -0500 Subject: [PATCH 10/39] switch branch to release/v4.0 Signed-off-by: Adam Hill --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 08e4384..3736e53 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ export USE_FTLDNS_BRANCHES=true export USE_DEVELOPMENT_BRANCHES=false if [[ $USE_FTLDNS_BRANCHES == true ]] ; then - CORE_TAG='FTLDNS' + CORE_TAG='release/v4.0' elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then CORE_TAG='development' fi From e7f5433d98dbfb28c86e62d79a88235c590f530e Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Wed, 1 Aug 2018 19:00:39 -0500 Subject: [PATCH 11/39] Checkout to the new release branch not old FTLDNS one Signed-off-by: Adam Hill --- install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 3736e53..489c43c 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,6 @@ mkdir -p /etc/pihole/ mkdir -p /var/run/pihole export CORE_TAG='v3.3.1' export WEB_TAG='v3.3' -export FTL_TAG='v3.0' export USE_FTLDNS_BRANCHES=true export USE_DEVELOPMENT_BRANCHES=false @@ -65,9 +64,9 @@ mv "${tmpLog}" / if [[ $USE_FTLDNS_BRANCHES == true ]] ; then ln -s /bin/true /usr/local/bin/service - echo "FTLDNS" | tee /etc/pihole/ftlbranch - echo y | bash -x pihole checkout core FTLDNS - echo y | bash -x pihole checkout web FTLDNS + echo "$CORE_TAG" | tee /etc/pihole/ftlbranch + echo y | bash -x pihole checkout core $CORE_TAG + echo y | bash -x pihole checkout web $CORE_TAG unlink /usr/local/bin/service elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then ln -s /bin/true /usr/local/bin/service From e7ae12a94c11bf770c5638e53a2dc8f95febeaac Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 2 Aug 2018 22:49:55 -0500 Subject: [PATCH 12/39] Add fixes for config permissions, deprection notice --- bash_functions.sh | 37 ++++++++++++++++++- install.sh | 2 +- .../etc/services.d/pihole-FTL/finish | 1 + start.sh | 12 +++++- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 8acf059..cf54460 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -1,7 +1,42 @@ #!/bin/bash -prepare_setup_vars() { +prepare_configs() { + PH_TEST=true . $PIHOLE_INSTALL + distro_check + installConfigs touch "$setupVars" + set +e + mkdir -p /var/run/pihole /var/log/pihole + # Re-apply perms from basic-install over any volume mounts that may be present (or not) + chown pihole:root /etc/lighttpd + chown pihole:pihole "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" "/var/log/pihole" "${regexFile}" + chmod 644 "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" "${regexFile}" + touch /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log + chown pihole:pihole /var/run/pihole /var/log/pihole + test -f /var/run/pihole/FTL.sock && rm /var/run/pihole/FTL.sock + chown pihole:pihole /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /etc/pihole /etc/pihole/dhcp.leases /var/log/pihole.log + chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log + set -e + # Re-write all of the setupVars to ensure required ones are present (like QUERY_LOGGING) + + # If the setup variable file exists, + if [[ -e "${setupVars}" ]]; then + # update the variables in the file + sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}" + . "${setupVars}" + fi + # echo the information to the user + { + echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}" + echo "IPV4_ADDRESS=${IPV4_ADDRESS}" + echo "IPV6_ADDRESS=${IPV6_ADDRESS}" + echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}" + echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}" + echo "QUERY_LOGGING=${QUERY_LOGGING}" + echo "INSTALL_WEB_SERVER=${INSTALL_WEB_SERVER}" + echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}" + echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}" + }>> "${setupVars}" } validate_env() { diff --git a/install.sh b/install.sh index 489c43c..8fa3c7e 100755 --- a/install.sh +++ b/install.sh @@ -59,7 +59,7 @@ git clone "${webInterfaceGitUrl}" "${webInterfaceDir}" tmpLog="/tmp/pihole-install.log" installLogLoc="${installLogLoc}" -installPihole | tee "${tmpLog}" +installPihole 2>&1 | tee "${tmpLog}" mv "${tmpLog}" / if [[ $USE_FTLDNS_BRANCHES == true ]] ; then diff --git a/s6/debian-root/etc/services.d/pihole-FTL/finish b/s6/debian-root/etc/services.d/pihole-FTL/finish index 81bd65f..6cf7a12 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/finish +++ b/s6/debian-root/etc/services.d/pihole-FTL/finish @@ -1,4 +1,5 @@ #!/usr/bin/with-contenv bash s6-echo "Stopping pihole-FTL" +#killall -9 pihole-FTL /etc/init.d/pihole-FTL stop diff --git a/start.sh b/start.sh index 9f5e3d5..6018877 100755 --- a/start.sh +++ b/start.sh @@ -27,7 +27,7 @@ PH_TEST=true . $PIHOLE_INSTALL echo " ::: Starting docker specific setup for docker diginc/pi-hole" validate_env || exit 1 -prepare_setup_vars +prepare_configs change_setting "IPV4_ADDRESS" "$ServerIP" change_setting "IPV6_ADDRESS" "$ServerIPv6" setup_web_port "$WEB_PORT" @@ -42,4 +42,12 @@ test_configs [ -f /.piholeFirstBoot ] && rm /.piholeFirstBoot -echo "::: Docker start setup complete" +echo " ::: Docker start setup complete" + +#echo " ::: ::: ::: ::: ::: ::: ::: ::: ::: :::" +#echo " ::: Image moved / deprection notice" +#echo " ::: OLD IMAGE : diginc/pi-hole" +#echo " ::: NEW IMAGE : pihole/pi-hole" +#echo " ::: Please update your image references" +#echo " ::: ::: ::: ::: ::: ::: ::: ::: ::: :::" + From ae16d39016e0fe953e99bab0195bf66e6f4f6ad2 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 10:07:10 -0500 Subject: [PATCH 13/39] note about armel Signed-off-by: Adam Hill --- deploy_arm.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy_arm.sh b/deploy_arm.sh index db13241..efcfeb9 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -30,6 +30,8 @@ echo $dry ./Dockerfile.py if [[ "$branch" == 'master' ]] ; then + # ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole + # for tag in debian_armhf debian_aarch64 debian_armel; do for tag in debian_armhf debian_aarch64; do # Verison specific tags for ongoing history $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:v${version}_${tag} From 187c1d3f29bdb31d2bfdd8d86a8aaad04db7f722 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 10:30:18 -0500 Subject: [PATCH 14/39] stop using pihole init.d stop, may be going away Signed-off-by: Adam Hill --- s6/debian-root/etc/services.d/pihole-FTL/finish | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/s6/debian-root/etc/services.d/pihole-FTL/finish b/s6/debian-root/etc/services.d/pihole-FTL/finish index 6cf7a12..81c9bd9 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/finish +++ b/s6/debian-root/etc/services.d/pihole-FTL/finish @@ -1,5 +1,4 @@ #!/usr/bin/with-contenv bash s6-echo "Stopping pihole-FTL" -#killall -9 pihole-FTL -/etc/init.d/pihole-FTL stop +kill -9 $(pgrep pihole-FTL) From 73f05e6d3536c1e506bcbac2e3c4d6e51945f03b Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 11:40:31 -0500 Subject: [PATCH 15/39] A bunch of name changes Signed-off-by: Adam Hill --- Dockerfile.py | 29 +++++++++---------- Dockerfile.template | 8 ++--- ...rfile_debian_aarch64 => Dockerfile_aarch64 | 6 ++-- Dockerfile_debian_amd64 => Dockerfile_amd64 | 6 ++-- Dockerfile_debian_armel => Dockerfile_armel | 6 ++-- Dockerfile_debian_armhf => Dockerfile_armhf | 6 ++-- README.md | 28 +++++++++--------- deploy_arm.sh | 12 ++++---- docker_run.sh | 2 +- doco-example.yml | 2 +- jwilder-proxy-example-doco.yml | 2 +- start.sh | 18 +++++++----- traefik-docker-compose-example.md | 6 ++-- 13 files changed, 66 insertions(+), 65 deletions(-) rename Dockerfile_debian_aarch64 => Dockerfile_aarch64 (91%) rename Dockerfile_debian_amd64 => Dockerfile_amd64 (91%) rename Dockerfile_debian_armel => Dockerfile_armel (91%) rename Dockerfile_debian_armhf => Dockerfile_armhf (91%) diff --git a/Dockerfile.py b/Dockerfile.py index 8857d2b..c474d99 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -25,20 +25,18 @@ import testinfra THIS_DIR = os.path.dirname(os.path.abspath(__file__)) base_vars = { - 'name': 'diginc/pi-hole', + 'name': 'pihole/pihole', 'maintainer' : 'adam@diginc.us', 's6_version' : 'v1.21.4.0', } os_base_vars = { - 'debian': { - 'php_env_config': '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf', - 'php_error_log': '/var/log/lighttpd/error.log' - }, + 'php_env_config': '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf', + 'php_error_log': '/var/log/lighttpd/error.log' } images = { - 'debian': [ + 'v4.0': [ { 'base': 'debian:stretch', 'arch': 'amd64' @@ -63,7 +61,7 @@ def generate_dockerfiles(args): print " ::: Skipping Dockerfile generation" return - for os, archs in images.iteritems(): + for version, archs in images.iteritems(): for image in archs: if image['arch'] not in args['--arch'] or image['arch'] in args['--skip']: return @@ -71,9 +69,9 @@ def generate_dockerfiles(args): if image['arch'] == 'armel': s6arch = 'arm' merged_data = dict( - { 'os': os }.items() + + { 'version': version }.items() + base_vars.items() + - os_base_vars[os].items() + + os_base_vars.items() + image.items() + { 's6arch': s6arch }.items() ) @@ -81,7 +79,7 @@ def generate_dockerfiles(args): trim_blocks=True) template = j2_env.get_template('Dockerfile.template') - dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) + dockerfile = 'Dockerfile_{}'.format(image['arch']) with open(dockerfile, 'w') as f: f.write(template.render(pihole=merged_data)) @@ -96,16 +94,17 @@ def build_dockerfiles(args): if arch == 'amd64': docker_repo = 'pi-hole' - build(docker_repo, 'debian', arch, args) + # TODO make version an argument, or auto-detect branch for non production tags + build(docker_repo, 'v4.0', arch, args) -def build(docker_repo, os, arch, args): +def build(docker_repo, version, arch, args): run_local = testinfra.get_backend( "local://" ).get_module("Command").run - dockerfile = 'Dockerfile_{}_{}'.format(os, arch) - repo_tag = '{}:{}_{}'.format(docker_repo, os, arch) + dockerfile = 'Dockerfile_{}'.format(arch) + repo_tag = '{}:{}_{}'.format(docker_repo, version, arch) cached_image = '{}/{}'.format('diginc', repo_tag) no_cache = '' if args['--no-cache']: @@ -126,7 +125,7 @@ def build(docker_repo, os, arch, args): if __name__ == '__main__': - args = docopt(__doc__, version='Dockerfile 0.2') + args = docopt(__doc__, version='Dockerfile 1.0') # print args generate_dockerfiles(args) diff --git a/Dockerfile.template b/Dockerfile.template index 43253de..8f43533 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,10 +1,10 @@ FROM {{ pihole.base }} -LABEL image="{{ pihole.name }}:{{ pihole.os }}_{{ pihole.arch }}" +LABEL image="{{ pihole.name }}:{{ pihole.version }}_{{ pihole.arch }}" LABEL maintainer="{{ pihole.maintainer }}" -LABEL url="https://www.github.com/diginc/docker-pi-hole" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -ENV TAG {{ pihole.os }} +ENV VERSION {{ pihole.version }} ENV ARCH {{ pihole.arch }} ENV PATH /opt/pihole:${PATH} @@ -22,7 +22,7 @@ RUN apt-get update && bash -ex docker-install.sh 2>&1 ENTRYPOINT [ "/s6-init" ] -ADD s6/{{ pihole.os }}-root / +ADD s6/debian-root / COPY s6/service /usr/local/bin/service # php config start passes special ENVs into diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_aarch64 similarity index 91% rename from Dockerfile_debian_aarch64 rename to Dockerfile_aarch64 index ed63b32..8dd1bd8 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_aarch64 @@ -1,10 +1,10 @@ FROM multiarch/debian-debootstrap:arm64-stretch-slim -LABEL image="diginc/pi-hole:debian_aarch64" +LABEL image="pihole/pihole:v4.0_aarch64" LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/diginc/docker-pi-hole" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -ENV TAG debian +ENV VERSION v4.0 ENV ARCH aarch64 ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_debian_amd64 b/Dockerfile_amd64 similarity index 91% rename from Dockerfile_debian_amd64 rename to Dockerfile_amd64 index 77628ec..5bfab4d 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_amd64 @@ -1,10 +1,10 @@ FROM debian:stretch -LABEL image="diginc/pi-hole:debian_amd64" +LABEL image="pihole/pihole:v4.0_amd64" LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/diginc/docker-pi-hole" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -ENV TAG debian +ENV VERSION v4.0 ENV ARCH amd64 ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_debian_armel b/Dockerfile_armel similarity index 91% rename from Dockerfile_debian_armel rename to Dockerfile_armel index 17425d1..a2999e8 100644 --- a/Dockerfile_debian_armel +++ b/Dockerfile_armel @@ -1,10 +1,10 @@ FROM multiarch/debian-debootstrap:armel-stretch-slim -LABEL image="diginc/pi-hole:debian_armel" +LABEL image="pihole/pihole:v4.0_armel" LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/diginc/docker-pi-hole" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -ENV TAG debian +ENV VERSION v4.0 ENV ARCH armel ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_debian_armhf b/Dockerfile_armhf similarity index 91% rename from Dockerfile_debian_armhf rename to Dockerfile_armhf index f56b532..e38fe0d 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_armhf @@ -1,10 +1,10 @@ FROM multiarch/debian-debootstrap:armhf-stretch-slim -LABEL image="diginc/pi-hole:debian_armhf" +LABEL image="pihole/pihole:v4.0_armhf" LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/diginc/docker-pi-hole" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" -ENV TAG debian +ENV VERSION v4.0 ENV ARCH armhf ENV PATH /opt/pihole:${PATH} diff --git a/README.md b/README.md index 09a60db..990c09c 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 ~~and ARM~~ container with [Pi-hole](https://pi-hole.net) functionality. 1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv6l/ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. -2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [diginc/pi-hole-multiarch:debian_armhf](https://store.docker.com/community/images/diginc/pi-hole-multiarch/tags)) in the below `docker run` command +2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:debian_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command 3) Enjoy! -[![Build Status](https://api.travis-ci.org/diginc/docker-pi-hole.svg?branch=master)](https://travis-ci.org/diginc/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/diginc/pi-hole.svg?maxAge=604800)](https://store.docker.com/community/images/diginc/pi-hole) [![Docker Pulls](https://img.shields.io/docker/pulls/diginc/pi-hole.svg?maxAge=604800)](https://store.docker.com/community/images/diginc/pi-hole) +[![Build Status](https://api.travis-ci.org/diginc/docker-pi-hole.svg?branch=master)](https://travis-ci.org/diginc/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Join the chat at https://gitter.im/diginc/docker-pi-hole](https://badges.gitter.im/diginc/docker-pi-hole.svg)](https://gitter.im/diginc/docker-pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Running Pi-Hole Docker -[DockerCloud](https://store.docker.com/community/images/diginc/pi-hole) automatically builds the latest docker-pi-hole changes into images which can easily be pulled and ran with a simple `docker run` command. Changes and updates under development or testing can be found in the [dev tags](#development) section. +[DockerCloud](https://store.docker.com/community/images/pihole/pihole) automatically builds the latest docker-pi-hole changes into images which can easily be pulled and ran with a simple `docker run` command. Changes and updates under development or testing can be found in the [dev tags](#development) section. One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or dockers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/diginc/docker-pi-hole/blob/master/docker_run.sh) or summarized here: @@ -36,7 +36,7 @@ docker run -d \ -e ServerIPv6="${IPv6}" \ --restart=unless-stopped \ --cap-add=NET_ADMIN \ - diginc/pi-hole:latest + pihole/pihole:latest echo -n "Your password for https://${IP}/admin/ is " docker logs pihole 2> /dev/null | grep 'password:' @@ -95,31 +95,31 @@ If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I ## Docker tags and versioning -The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/diginc/pi-hole/tags) ([arm tags are here](https://store.docker.com/community/images/diginc/pi-hole-multiarch/tags)), I also try to tag with the specific version of Pi-Hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/diginc/docker-pi-hole/releases). +The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-Hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/diginc/docker-pi-hole/releases). | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | | `debian` / `latest` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/diginc/docker-pi-hole/blob/master/debian.docker) | | `alpine` | x86 | **Deprecated release** | | -### `diginc/pi-hole:debian` [![](https://images.microbadger.com/badges/image/diginc/pi-hole:debian.svg)](https://microbadger.com/images/diginc/pi-hole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/diginc/pi-hole:debian.svg)](https://microbadger.com/images/diginc/pi-hole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/diginc/pi-hole:latest.svg)](https://microbadger.com/images/diginc/pi-hole "Get your own version badge on microbadger.com") +### `pihole/pihole:debian` [![](https://images.microbadger.com/badges/image/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") This version of the docker aims to be as close to a standard pi-hole installation by using the recommended base OS and the exact configs and scripts (minimally modified to get them working). This enables fast updating when an update comes from pi-hole. -### `diginc/pi-hole-multiarch:debian_armhf` [![](https://images.microbadger.com/badges/image/diginc/pi-hole-multiarch:debian_armhf.svg)](https://microbadger.com/images/diginc/pi-hole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:debian_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARMv7-compatible pihole image -https://hub.docker.com/r/diginc/pi-hole-multiarch/tags/ +https://hub.docker.com/r/pihole/pihole-multiarch/tags/ -### `diginc/pi-hole-multiarch:debian_aarch64` [![](https://images.microbadger.com/badges/image/diginc/pi-hole-multiarch:debian_aarch64.svg)](https://microbadger.com/images/diginc/pi-hole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:debian_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARM64-compatible pihole image -https://hub.docker.com/r/diginc/pi-hole-multiarch/tags/ +https://hub.docker.com/r/pihole/pihole-multiarch/tags/ -### `diginc/pi-hole-multiarch:debian_armel` [![](https://images.microbadger.com/badges/image/diginc/pi-hole-multiarch:debian_armel.svg)](https://microbadger.com/images/diginc/pi-hole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:debian_armel` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_armel.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARMv6-compatible pihole image -https://hub.docker.com/r/diginc/pi-hole-multiarch/tags/ +https://hub.docker.com/r/pihole/pihole-multiarch/tags/ ## Upgrading, Persistence, and Customizations @@ -129,11 +129,11 @@ The standard pi-hole customization abilities apply to this docker, but with dock `pihole -up` is disabled. Upgrade the docker way instead, please. Long-living docker containers are not the docker way. -1. Download the latest version of the image: `docker pull diginc/pi-hole` +1. Download the latest version of the image: `docker pull pihole/pihole` 2. Throw away your container: `docker rm -f pihole` * **Warning** When removing your pihole container you may be stuck without DNS until step 3; **docker pull** before **docker rm -f** to avoid DNS inturruption **OR** always have a fallback DNS server configured in DHCP to avoid this problem altogether. * If you care about your data (logs/customizations), make sure you have it volume-mapped or it will be deleted in this step. -3. Start your container with the newer base image: `docker run diginc/pi-hole` (`` being your preferred run volumes and env vars) +3. Start your container with the newer base image: `docker run pihole/pihole` (`` being your preferred run volumes and env vars) Why is this style of upgrading good? A couple reasons: Everyone is starting from the same base image which has been tested to know it works. No worrying about upgrading from A to B, B to C, or A to C is required when rolling out updates, it reducing complexity, and simply allows a 'fresh start' every time while preserving customizations with volumes. Basically I'm encouraging [phoenix servers](https://www.google.com/?q=phoenix+servers) principles for your containers. diff --git a/deploy_arm.sh b/deploy_arm.sh index efcfeb9..5d6d50a 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -34,15 +34,15 @@ if [[ "$branch" == 'master' ]] ; then # for tag in debian_armhf debian_aarch64 debian_armel; do for tag in debian_armhf debian_aarch64; do # Verison specific tags for ongoing history - $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:v${version}_${tag} - $dry docker push diginc/pi-hole-multiarch:v${version}_${tag} + $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:v${version}_${tag} + $dry docker push pihole/pihole-multiarch:v${version}_${tag} # Floating latest tags - $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag} - $dry docker push diginc/pi-hole-multiarch:${tag} + $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag} + $dry docker push pihole/pihole-multiarch:${tag} done else for tag in debian_armhf debian_aarch64; do - $dry docker tag pi-hole-multiarch:$tag diginc/pi-hole-multiarch:${tag}_${branch} - $dry docker push diginc/pi-hole-multiarch:${tag}_${branch} + $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag}_${branch} + $dry docker push pihole/pihole-multiarch:${tag}_${branch} done fi diff --git a/docker_run.sh b/docker_run.sh index 2b1b35f..f91187e 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -24,7 +24,7 @@ docker run -d \ -e ServerIP="${IP}" \ -e ServerIPv6="${IPv6}" \ --restart=unless-stopped \ - diginc/pi-hole:latest + pihole/pihole:latest echo -n "Your password for https://${IP}/admin/ is " docker logs pihole 2> /dev/null | grep 'password:' diff --git a/doco-example.yml b/doco-example.yml index fbc1f08..2047657 100644 --- a/doco-example.yml +++ b/doco-example.yml @@ -1,7 +1,7 @@ version: "3" services: pihole: - image: diginc/pi-hole:latest + image: pihole/pihole:latest ports: - "53:53/tcp" - "53:53/udp" diff --git a/jwilder-proxy-example-doco.yml b/jwilder-proxy-example-doco.yml index f9c9608..280667c 100644 --- a/jwilder-proxy-example-doco.yml +++ b/jwilder-proxy-example-doco.yml @@ -9,7 +9,7 @@ applist: restart: always pihole: - image: diginc/pi-hole:latest + image: pihole/pihole:latest ports: - '53:53/tcp' - '53:53/udp' diff --git a/start.sh b/start.sh index 6018877..aaa3972 100755 --- a/start.sh +++ b/start.sh @@ -25,7 +25,7 @@ export adlistFile='/etc/pihole/adlists.list' # PH_TEST prevents the install from actually running (someone should rename that) PH_TEST=true . $PIHOLE_INSTALL -echo " ::: Starting docker specific setup for docker diginc/pi-hole" +echo " ::: Starting docker specific setup for docker pihole/pihole" validate_env || exit 1 prepare_configs change_setting "IPV4_ADDRESS" "$ServerIP" @@ -44,10 +44,12 @@ test_configs echo " ::: Docker start setup complete" -#echo " ::: ::: ::: ::: ::: ::: ::: ::: ::: :::" -#echo " ::: Image moved / deprection notice" -#echo " ::: OLD IMAGE : diginc/pi-hole" -#echo " ::: NEW IMAGE : pihole/pi-hole" -#echo " ::: Please update your image references" -#echo " ::: ::: ::: ::: ::: ::: ::: ::: ::: :::" - +echo > +:: ::: ::: ::: ::: ::: ::: ::: ::: ::: +:: Image moved / deprecation notice +:: OLD IMAGE : diginc/pi-hole +:: NEW IMAGE : pihole/pihole +:: In order to get the latest updates +:: please update your image references +:: ::: ::: ::: ::: ::: ::: ::: ::: ::: +EOF diff --git a/traefik-docker-compose-example.md b/traefik-docker-compose-example.md index 083724a..250b47f 100644 --- a/traefik-docker-compose-example.md +++ b/traefik-docker-compose-example.md @@ -43,7 +43,7 @@ services: container_name: pihole domainname: homedomain.lan - image: diginc/pi-hole:debian + image: pihole/pihole:debian ports: - '0.0.0.0:53:53/tcp' - '0.0.0.0:53:53/udp' @@ -82,8 +82,8 @@ networks: After running `docker-compose up -d` you should see this if you look at logs on traefik `docker-compose logs -f traefik` ``` -traefik | time="2018-03-07T18:57:41Z" level=debug msg="Provider event received {Status:health_status: healthy ID:33567e94e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 From:diginc/pi-hole:debian Type:container Action:health_status: healthy Actor:{ID:33567e94 -e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:diginc/pi-hole:debian traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/diginc/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- +traefik | time="2018-03-07T18:57:41Z" level=debug msg="Provider event received {Status:health_status: healthy ID:33567e94e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 From:pihole/pihole:debian Type:container Action:health_status: healthy Actor:{ID:33567e94 +e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:pihole/pihole:debian traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/diginc/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- hash:7551c3f4bd11766292c7dad81473ef21da91cae8666d1b04a42d1daab53fba0f]} Scope:local Time:1520449061 TimeNano:1520449061934970670}" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Filtering disabled container /traefik" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Could not load traefik.frontend.whitelistSourceRange labels" From 805c5ccdb7483d88f4c3fa10ac1ce9d5ed84c8b1 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 11:44:19 -0500 Subject: [PATCH 16/39] more /diginc/ references updated Signed-off-by: Adam Hill --- Dockerfile.py | 2 +- README.md | 22 +++++++++++----------- TESTING.md | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Dockerfile.py b/Dockerfile.py index c474d99..f068b22 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -105,7 +105,7 @@ def build(docker_repo, version, arch, args): dockerfile = 'Dockerfile_{}'.format(arch) repo_tag = '{}:{}_{}'.format(docker_repo, version, arch) - cached_image = '{}/{}'.format('diginc', repo_tag) + cached_image = '{}/{}'.format('pihole', repo_tag) no_cache = '' if args['--no-cache']: no_cache = '--no-cache' diff --git a/README.md b/README.md index 990c09c..e25a44c 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:debian_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command 3) Enjoy! -[![Build Status](https://api.travis-ci.org/diginc/docker-pi-hole.svg?branch=master)](https://travis-ci.org/diginc/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) +[![Build Status](https://api.travis-ci.org/pihole/docker-pi-hole.svg?branch=master)](https://travis-ci.org/pihole/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) -[![Join the chat at https://gitter.im/diginc/docker-pi-hole](https://badges.gitter.im/diginc/docker-pi-hole.svg)](https://gitter.im/diginc/docker-pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/pihole/docker-pi-hole](https://badges.gitter.im/pihole/docker-pi-hole.svg)](https://gitter.im/pihole/docker-pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Running Pi-Hole Docker [DockerCloud](https://store.docker.com/community/images/pihole/pihole) automatically builds the latest docker-pi-hole changes into images which can easily be pulled and ran with a simple `docker run` command. Changes and updates under development or testing can be found in the [dev tags](#development) section. -One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or dockers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/diginc/docker-pi-hole/blob/master/docker_run.sh) or summarized here: +One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or dockers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/pihole/docker-pi-hole/blob/master/docker_run.sh) or summarized here: ``` IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 @@ -77,7 +77,7 @@ Here is a rundown of the other arguments passed into the example `docker run`: | `--net=host`
*Optional* | Alternative to `-p :` arguments (Cannot be used at same time as -p) if you don't run any other web application | `--cap-add=NET_ADMIN`
*Optional* | If you're forwarding port 67 you will also needs this for DHCP to work. (DHCP Reportedly works, I have not used however) -If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I have [example docker-compose.yml files](https://github.com/diginc/docker-pi-hole/blob/master/doco-example.yml) in github which I think are a nicer way to represent such long run commands. +If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I have [example docker-compose.yml files](https://github.com/pihole/docker-pi-hole/blob/master/doco-example.yml) in github which I think are a nicer way to represent such long run commands. ## Tips and Tricks @@ -91,15 +91,15 @@ If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I * Don't forget to stop your services from auto-starting again after you reboot * Port 80 is highly recommended because if you have another site/service using port 80 by default then the ads may not transform into blank ads correctly. To make sure docker-pi-hole plays nicely with an existing webserver you run you'll probably need a reverse proxy webserver config if you don't have one already. Pi-Hole must be the default web app on the proxy e.g. if you go to your host by IP instead of domain then pi-hole is served out instead of any other sites hosted by the proxy. This is the '[default_server](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)' in nginx or ['_default_' virtual host](https://httpd.apache.org/docs/2.4/vhosts/examples.html#default) in Apache and is taken advantage of so any undefined ad domain can be directed to your webserver and get a 'blocked' response instead of ads. * You can still map other ports to pi-hole port 80 using docker's port forwarding like this `-p 8080:80`, but again the ads won't render properly. Changing the inner port 80 shouldn't be required unless you run docker host networking mode. - * [Here is an example of running with jwilder/proxy](https://github.com/diginc/docker-pi-hole/blob/master/jwilder-proxy-example-doco.yml) (an nginx auto-configuring docker reverse proxy for docker) on my port 80 with Pi-hole on another port. Pi-hole needs to be `DEFAULT_HOST` env in jwilder/proxy and you need to set the matching `VIRTUAL_HOST` for the Pi-hole's container. Please read jwilder/proxy readme for more info if you have trouble. I tested this basic example which is based off what I run. + * [Here is an example of running with jwilder/proxy](https://github.com/pihole/docker-pi-hole/blob/master/jwilder-proxy-example-doco.yml) (an nginx auto-configuring docker reverse proxy for docker) on my port 80 with Pi-hole on another port. Pi-hole needs to be `DEFAULT_HOST` env in jwilder/proxy and you need to set the matching `VIRTUAL_HOST` for the Pi-hole's container. Please read jwilder/proxy readme for more info if you have trouble. I tested this basic example which is based off what I run. ## Docker tags and versioning -The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-Hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/diginc/docker-pi-hole/releases). +The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-Hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/pihole/docker-pi-hole/releases). | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | -| `debian` / `latest` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/diginc/docker-pi-hole/blob/master/debian.docker) | +| `debian` / `latest` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/master/debian.docker) | | `alpine` | x86 | **Deprecated release** | | ### `pihole/pihole:debian` [![](https://images.microbadger.com/badges/image/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") @@ -156,18 +156,18 @@ Similarly for the webserver you can customize configs in /etc/lighttpd (*:debian ### Systemd init script -As long as your docker system service auto starts on boot and you run your container with `--restart=unless-stopped` your container should always start on boot and restart on crashes. If you prefer to have your docker container run as a systemd service instead, add the file [pihole.service](https://raw.githubusercontent.com/diginc/docker-pi-hole/master/pihole.service) to "/etc/systemd/system"; customize whatever your container name is and remove `--restart=unless-stopped` from your docker run. Then after you have initially created the docker container using the docker run command above, you can control it with "systemctl start pihole" or "systemctl stop pihole" (instead of `docker start`/`docker stop`). You can also enable it to auto-start on boot with "systemctl enable pihole" (as opposed to `--restart=unless-stopped` and making sure docker service auto-starts on boot). +As long as your docker system service auto starts on boot and you run your container with `--restart=unless-stopped` your container should always start on boot and restart on crashes. If you prefer to have your docker container run as a systemd service instead, add the file [pihole.service](https://raw.githubusercontent.com/pihole/docker-pi-hole/master/pihole.service) to "/etc/systemd/system"; customize whatever your container name is and remove `--restart=unless-stopped` from your docker run. Then after you have initially created the docker container using the docker run command above, you can control it with "systemctl start pihole" or "systemctl stop pihole" (instead of `docker start`/`docker stop`). You can also enable it to auto-start on boot with "systemctl enable pihole" (as opposed to `--restart=unless-stopped` and making sure docker service auto-starts on boot). NOTE: After initial run you may need to manually stop the docker container with "docker stop pihole" before the systemctl can start controlling the container. ## Development -[![Build Status](https://api.travis-ci.org/diginc/docker-pi-hole.svg?branch=dev)](https://travis-ci.org/diginc/docker-pi-hole) If you plan on making a contribution please pull request to the dev branch. I also build tags of the dev branch for bug fix testing after merges have been made: +[![Build Status](https://api.travis-ci.org/pihole/docker-pi-hole.svg?branch=dev)](https://travis-ci.org/pihole/docker-pi-hole) If you plan on making a contribution please pull request to the dev branch. I also build tags of the dev branch for bug fix testing after merges have been made: | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | -| `debian_dev` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/diginc/docker-pi-hole/blob/dev/debian.docker) | +| `debian_dev` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/dev/debian.docker) | # User Feedback -Please report issues on the [GitHub project](https://github.com/diginc/docker-pi-hole) when you suspect something docker related. Pi-Hole questions are best answered on their [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on there if it's a docker and you're not sure if it's docker related. +Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-Hole questions are best answered on their [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on there if it's a docker and you're not sure if it's docker related. diff --git a/TESTING.md b/TESTING.md index e0be1c4..30438d4 100644 --- a/TESTING.md +++ b/TESTING.md @@ -12,7 +12,7 @@ To run the Dockerfile templating, image build, and tests all in one command just # Local image names -Docker images built by `tox` or `python Dockerfile.py` are named the same but stripped of the `diginc/` docker repository namespace. +Docker images built by `tox` or `python Dockerfile.py` are named the same but stripped of the `pihole/` docker repository namespace. e.g. `pi-hole:debian_amd64` or `pi-hole-multiarch:debian_aarch64` From 5b1e992d66efc6892825d244ef96ca1b46b98d77 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 11:53:12 -0500 Subject: [PATCH 17/39] missed one file Signed-off-by: Adam Hill --- traefik-docker-compose-example.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/traefik-docker-compose-example.md b/traefik-docker-compose-example.md index 250b47f..a5224fc 100644 --- a/traefik-docker-compose-example.md +++ b/traefik-docker-compose-example.md @@ -1,6 +1,6 @@ Please note the following about this [traefik](https://traefik.io/) example for pihole. -- Still requires standard pi-hole setup steps, make sure you've gone through the [README](https://github.com/diginc/docker-pi-hole/blob/master/README.md) and understand how to setup pihole without traefik first +- Still requires standard pi-hole setup steps, make sure you've gone through the [README](https://github.com/pihole/docker-pi-hole/blob/master/README.md) and understand how to setup pihole without traefik first - Update these things before using: - set instances of `homedomain.lan` below to your home domain (typically set in your router) - set your pihole ENV WEBPASSWORD if you don't want a random admin pass @@ -83,7 +83,7 @@ After running `docker-compose up -d` you should see this if you look at logs on ``` traefik | time="2018-03-07T18:57:41Z" level=debug msg="Provider event received {Status:health_status: healthy ID:33567e94e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 From:pihole/pihole:debian Type:container Action:health_status: healthy Actor:{ID:33567e94 -e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:pihole/pihole:debian traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/diginc/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- +e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:pihole/pihole:debian traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/pihole/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- hash:7551c3f4bd11766292c7dad81473ef21da91cae8666d1b04a42d1daab53fba0f]} Scope:local Time:1520449061 TimeNano:1520449061934970670}" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Filtering disabled container /traefik" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Could not load traefik.frontend.whitelistSourceRange labels" From 6e15abd002bf116aec5418646041ac1b0f42cbd2 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 12:06:51 -0500 Subject: [PATCH 18/39] more readme old debian tags Signed-off-by: Adam Hill --- README.md | 21 ++++++++++++--------- traefik-docker-compose-example.md | 6 +++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e25a44c..746f009 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 ~~and ARM~~ container with [Pi-hole](https://pi-hole.net) functionality. 1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv6l/ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. -2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:debian_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command +2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command 3) Enjoy! [![Build Status](https://api.travis-ci.org/pihole/docker-pi-hole.svg?branch=master)](https://travis-ci.org/pihole/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) @@ -99,24 +99,23 @@ The primary docker tags / versions are explained in the following table. [Click | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | -| `debian` / `latest` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/master/debian.docker) | -| `alpine` | x86 | **Deprecated release** | | +| `latest` / `v4.0` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/master/Dockerfile_amd64) | -### `pihole/pihole:debian` [![](https://images.microbadger.com/badges/image/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:debian.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") +### `pihole/pihole:latest` [![](https://images.microbadger.com/badges/image/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") This version of the docker aims to be as close to a standard pi-hole installation by using the recommended base OS and the exact configs and scripts (minimally modified to get them working). This enables fast updating when an update comes from pi-hole. -### `pihole/pihole-multiarch:debian_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:v4.0_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:v4.0_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARMv7-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ -### `pihole/pihole-multiarch:debian_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:v4.0_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:v4.0_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARM64-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ -### `pihole/pihole-multiarch:debian_armel` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:debian_armel.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole-multiarch:v4.0_armel` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:v4.0_armel.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARMv6-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ @@ -152,7 +151,7 @@ We install all pihole utilities so the the built in [pihole commands](https://di The webserver and DNS service inside the container can be customized if necessary. Any configuration files you volume mount into `/etc/dnsmasq.d/` will be loaded by dnsmasq when the container starts or restarts or if you need to modify the pi-hole config it is located at `/etc/dnsmasq.d/01-pihole.conf`. The docker start scripts runs a config test prior to starting so it will tell you about any errors in the docker log. -Similarly for the webserver you can customize configs in /etc/lighttpd (*:debian* tag). +Similarly for the webserver you can customize configs in /etc/lighttpd ### Systemd init script @@ -162,11 +161,15 @@ NOTE: After initial run you may need to manually stop the docker container with ## Development +Development image tags coming soon + + # User Feedback diff --git a/traefik-docker-compose-example.md b/traefik-docker-compose-example.md index a5224fc..a76108b 100644 --- a/traefik-docker-compose-example.md +++ b/traefik-docker-compose-example.md @@ -43,7 +43,7 @@ services: container_name: pihole domainname: homedomain.lan - image: pihole/pihole:debian + image: pihole/pihole:latest ports: - '0.0.0.0:53:53/tcp' - '0.0.0.0:53:53/udp' @@ -82,8 +82,8 @@ networks: After running `docker-compose up -d` you should see this if you look at logs on traefik `docker-compose logs -f traefik` ``` -traefik | time="2018-03-07T18:57:41Z" level=debug msg="Provider event received {Status:health_status: healthy ID:33567e94e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 From:pihole/pihole:debian Type:container Action:health_status: healthy Actor:{ID:33567e94 -e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:pihole/pihole:debian traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/pihole/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- +traefik | time="2018-03-07T18:57:41Z" level=debug msg="Provider event received {Status:health_status: healthy ID:33567e94e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 From:pihole/pihole:latest Type:container Action:health_status: healthy Actor:{ID:33567e94 +e02c5adba3d47fa44c391e94fdea359fb05eecb196c95de288ffb861 Attributes:map[com.docker.compose.project:traefik image:pihole/pihole:latest traefik.frontend.priority:1 com.docker.compose.container-number:1 com.docker.compose.service:pihole com.docker.compose.version:1.19.0 name:pihole traefik.enable:true url:https://www.github.com/pihole/docker-pi-hole com.docker.compose.oneoff:False maintainer:adam@diginc.us traefik.backend:pihole traefik.frontend.rule:HostRegexp:pihole.homedomain.lan,{catchall:.*} traefik.port:80 com.docker.compose.config- hash:7551c3f4bd11766292c7dad81473ef21da91cae8666d1b04a42d1daab53fba0f]} Scope:local Time:1520449061 TimeNano:1520449061934970670}" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Filtering disabled container /traefik" traefik | time="2018-03-07T18:57:42Z" level=debug msg="Could not load traefik.frontend.whitelistSourceRange labels" From 80d5b9dbc19da0990ace3963415cd8bc3a63a4cb Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 13:31:58 -0500 Subject: [PATCH 19/39] Test image name updates, passing locally. reorg Dockerfile to build fast, starting on new deploy Signed-off-by: Adam Hill --- Dockerfile.py | 8 ++----- Dockerfile.template | 16 ++++++------- Dockerfile_amd64 | 16 ++++++------- bash_functions.sh | 36 ++++++++++++++-------------- deploy_arm.sh | 30 +++++++++++++---------- start.sh | 4 ++-- test/conftest.py | 47 +++++++++++++++++-------------------- test/test_bash_functions.py | 29 +++++++++++------------ 8 files changed, 92 insertions(+), 94 deletions(-) diff --git a/Dockerfile.py b/Dockerfile.py index f068b22..c79c000 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -90,12 +90,8 @@ def build_dockerfiles(args): return for arch in args['--arch']: - docker_repo = 'pi-hole-multiarch' - if arch == 'amd64': - docker_repo = 'pi-hole' - - # TODO make version an argument, or auto-detect branch for non production tags - build(docker_repo, 'v4.0', arch, args) + # TODO: include from external .py that can be shared with Dockerfile.py / Tests / deploy scripts ''' + build('pihole', 'v4.0', arch, args) def build(docker_repo, version, arch, args): diff --git a/Dockerfile.template b/Dockerfile.template index 8f43533..ea6c449 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,13 +1,5 @@ FROM {{ pihole.base }} -LABEL image="{{ pihole.name }}:{{ pihole.version }}_{{ pihole.arch }}" -LABEL maintainer="{{ pihole.maintainer }}" -LABEL url="https://www.github.com/pi-hole/docker-pi-hole" - -ENV VERSION {{ pihole.version }} -ENV ARCH {{ pihole.arch }} -ENV PATH /opt/pihole:${PATH} - COPY install.sh /usr/local/bin/docker-install.sh ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ pihole.s6_version }}/s6-overlay-{{ pihole.s6arch }}.tar.gz @@ -44,6 +36,14 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 ENV FTL_CMD no-daemon +ENV VERSION {{ pihole.version }} +ENV ARCH {{ pihole.arch }} +ENV PATH /opt/pihole:${PATH} + +LABEL image="{{ pihole.name }}:{{ pihole.version }}_{{ pihole.arch }}" +LABEL maintainer="{{ pihole.maintainer }}" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" + HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"] diff --git a/Dockerfile_amd64 b/Dockerfile_amd64 index 5bfab4d..08e6066 100644 --- a/Dockerfile_amd64 +++ b/Dockerfile_amd64 @@ -1,13 +1,5 @@ FROM debian:stretch -LABEL image="pihole/pihole:v4.0_amd64" -LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/pi-hole/docker-pi-hole" - -ENV VERSION v4.0 -ENV ARCH amd64 -ENV PATH /opt/pihole:${PATH} - COPY install.sh /usr/local/bin/docker-install.sh ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-amd64.tar.gz @@ -44,6 +36,14 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 ENV FTL_CMD no-daemon +ENV VERSION v4.0 +ENV ARCH amd64 +ENV PATH /opt/pihole:${PATH} + +LABEL image="pihole/pihole:v4.0_amd64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" + HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/bash_functions.sh b/bash_functions.sh index cf54460..9d28f20 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -223,23 +223,25 @@ setup_web_port() { } setup_web_password() { - if [ -z "${WEBPASSWORD+x}" ] ; then - # Not set at all, give the user a random pass - WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) - echo "Assigning random password: $WEBPASSWORD" - fi; - # Turn bash debug on while setting up password (to print it) - set -x - if [[ "$WEBPASSWORD" == "" ]] ; then - echo "" | pihole -a -p - else - pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" - fi - if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then - # Turn bash debug back off after print password setup - # (subshell to null hides printing output) - { set +x; } 2>/dev/null - fi + #if ! grep -q 'WEBPASSWORD' ${setupVars}; then + if [ -z "${WEBPASSWORD+x}" ] ; then + # Not set at all, give the user a random pass + WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) + echo "Assigning random password: $WEBPASSWORD" + fi; + # Turn bash debug on while setting up password (to print it) + set -x + if [[ "$WEBPASSWORD" == "" ]] ; then + echo "" | pihole -a -p + else + pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" + fi + if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then + # Turn bash debug back off after print password setup + # (subshell to null hides printing output) + { set +x; } 2>/dev/null + fi + #fi } setup_ipv4_ipv6() { diff --git a/deploy_arm.sh b/deploy_arm.sh index 5d6d50a..0803274 100755 --- a/deploy_arm.sh +++ b/deploy_arm.sh @@ -10,39 +10,45 @@ parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' } +namespace='pihole' +localimg='pihole' +remoteimg="$namespace/$localimg" branch="$(parse_git_branch)" version="${version:-unset}" dry="${dry}" if [[ -n "$dry" ]] ; then dry='echo ' ; fi -if [[ "$version" == 'unset' && "$branch" == 'master' ]]; then - echo "Version is unset and master/prod branch wants a version...pass in \$version!" - exit 1 +if [[ "$version" == 'unset' ]]; then + version="$branch" + if [[ "$branch" == "master" ]]; then + echo "Version number var is unset and master branch needs a version...pass in \$version variable!" + exit 1 + else if [[ "$branch" = "release/"* ]] + echo "Version number is being taken from this release branch" + version="$(echo $branch | grep -Po 'v[\d.-]')" + fi + echo "Using the branch ($branch) for deployed image version since not passed in" fi echo "# DEPLOYING:" echo "version: $version" echo "branch: $branch" [[ -n "$dry" ]] && echo "DRY RUN: $dry" +echo "Example tagging: docker tag $localimg:$tag $remoteimg:${version}_${tag}" echo $dry ./Dockerfile.py -if [[ "$branch" == 'master' ]] ; then +if [[ "$branch" == "master" ]] || [[ "$branch" = "release/"* ]] ; then # ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole # for tag in debian_armhf debian_aarch64 debian_armel; do - for tag in debian_armhf debian_aarch64; do + for tag in amd64 armhf aarch64; do # Verison specific tags for ongoing history - $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:v${version}_${tag} - $dry docker push pihole/pihole-multiarch:v${version}_${tag} + $dry docker tag $localimg:$tag $remoteimg:${version}_${tag} + $dry docker push pihole/pihole-multiarch:${version}_${tag} # Floating latest tags $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag} $dry docker push pihole/pihole-multiarch:${tag} done -else - for tag in debian_armhf debian_aarch64; do - $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag}_${branch} - $dry docker push pihole/pihole-multiarch:${tag}_${branch} - done fi diff --git a/start.sh b/start.sh index aaa3972..460e3e1 100755 --- a/start.sh +++ b/start.sh @@ -44,7 +44,7 @@ test_configs echo " ::: Docker start setup complete" -echo > +echo """ :: ::: ::: ::: ::: ::: ::: ::: ::: ::: :: Image moved / deprecation notice :: OLD IMAGE : diginc/pi-hole @@ -52,4 +52,4 @@ echo > :: In order to get the latest updates :: please update your image references :: ::: ::: ::: ::: ::: ::: ::: ::: ::: -EOF +""" diff --git a/test/conftest.py b/test/conftest.py index 82af26e..897e1ec 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -7,7 +7,7 @@ check_output = testinfra.get_backend( def DockerGeneric(request, args, image, cmd): assert 'docker' in check_output('id'), "Are you in the docker group?" - if 'pi-hole' in image: + if 'pihole' in image: args += " --dns 127.0.0.1 -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\"" docker_run = "docker run -d {} {} {}".format(args, image, cmd) print docker_run @@ -44,7 +44,8 @@ def Docker(request, args, image, cmd): @pytest.fixture(scope='module') def DockerPersist(request, persist_args, persist_image, persist_cmd, Dig): - ''' Persistent Docker container for multiple tests ''' + ''' Persistent Docker container for multiple tests, instead of stopping container after one test ''' + ''' Uses DUP'd module scoped fixtures because smaller scoped fixtures won't mix with module scope ''' persistent_container = DockerGeneric(request, persist_args, persist_image, persist_cmd) ''' attach a dig conatiner for lookups ''' persistent_container.dig = Dig(persistent_container.id) @@ -58,26 +59,23 @@ def args(request): def arch(request): return request.param -@pytest.fixture(params=['debian']) -def os(request): - return request.param +@pytest.fixture() +def version(request): + ''' TODO: include from external .py that can be shared with Dockerfile.py / Tests / deploy scripts ''' + return 'v4.0' @pytest.fixture() -def tag(request, os, arch): - return '{}_{}'.format(os, arch) +def tag(request, version, arch): + return '{}_{}'.format(version, arch) @pytest.fixture def webserver(request, tag): - webserver = 'nginx' - if 'debian' in tag: - webserver = 'lighttpd' - return webserver + ''' TODO: this is obvious without alpine+nginx as the alternative, remove fixture, hard code lighttpd in tests? ''' + return 'lighttpd' @pytest.fixture() def image(request, tag): - image = 'pi-hole-multiarch' - if 'amd64' in tag: - image = 'pi-hole' + image = 'pihole' return '{}:{}'.format(image, tag) @pytest.fixture() @@ -89,30 +87,27 @@ def persist_arch(request): '''amd64 only, dnsmasq/pihole-FTL(?untested?) will not start under qemu-user-static :(''' return request.param -@pytest.fixture(scope='module', params=['debian']) -def persist_os(request): - return request.param +@pytest.fixture(scope='module') +def persist_version(request): + ''' TODO: include from external .py that can be shared with Dockerfile.py / Tests / deploy scripts ''' + return 'v4.0' @pytest.fixture(scope='module') def persist_args(request): return '-e ServerIP="127.0.0.1" -e ServerIPv6="::1"' @pytest.fixture(scope='module') -def persist_tag(request, persist_os, persist_arch): - return '{}_{}'.format(persist_os, persist_arch) +def persist_tag(request, persist_version, persist_arch): + return '{}_{}'.format(persist_version, persist_arch) @pytest.fixture(scope='module') def persist_webserver(request, persist_tag): - webserver = 'nginx' - if 'debian' in persist_tag: - webserver = 'lighttpd' - return webserver + ''' TODO: this is obvious without alpine+nginx as the alternative, remove fixture, hard code lighttpd in tests? ''' + return 'lighttpd' @pytest.fixture(scope='module') def persist_image(request, persist_tag): - image = 'pi-hole-multiarch' - if 'amd64' in persist_tag: - image = 'pi-hole' + image = 'pihole' return '{}:{}'.format(image, persist_tag) @pytest.fixture(scope='module') diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index b2e5c6f..4b4bbe4 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -9,28 +9,27 @@ DEFAULTARGS = '-e ServerIP="127.0.0.1" ' (DEFAULTARGS + '-e "IPv6=False"', False, 'IPv4'), (DEFAULTARGS + '-e "IPv6=foobar"', False, 'IPv4'), ]) -def test_IPv6_not_True_removes_ipv6(Docker, os, args, expected_ipv6, expected_stdout): +def test_IPv6_not_True_removes_ipv6(Docker, args, expected_ipv6, expected_stdout): ''' When a user overrides IPv6=True they only get IPv4 listening webservers ''' - IPV6_LINE = { 'debian': 'use-ipv6.pl' } - WEB_CONFIG = { 'debian': '/etc/lighttpd/lighttpd.conf' } + IPV6_LINE = 'use-ipv6.pl' + WEB_CONFIG = '/etc/lighttpd/lighttpd.conf' function = Docker.run('. /bash_functions.sh ; setup_ipv4_ipv6') assert "Using {}".format(expected_stdout) in function.stdout - config = Docker.run('cat {}'.format( WEB_CONFIG[os])).stdout - assert (IPV6_LINE[os] in config) == expected_ipv6 + config = Docker.run('cat {}'.format(WEB_CONFIG)).stdout + assert (IPV6_LINE in config) == expected_ipv6 @pytest.mark.parametrize('args', [DEFAULTARGS + '-e "WEB_PORT=999"']) -def test_overrides_default_WEB_PORT(Docker, os, args): +def test_overrides_default_WEB_PORT(Docker, args): ''' When a --net=host user sets WEB_PORT to avoid synology's 80 default IPv4 and or IPv6 ports are updated''' - CONFIG_LINES = { 'debian': ['server.port\s*=\s*999'] } - WEB_CONFIG = { 'debian': '/etc/lighttpd/lighttpd.conf' } + CONFIG_LINE = 'server.port\s*=\s*999' + WEB_CONFIG = '/etc/lighttpd/lighttpd.conf' function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_port /start.sh`') assert "Custom WEB_PORT set to 999" in function.stdout assert "INFO: Without proper router DNAT forwarding to 127.0.0.1:999, you may not get any blocked websites on ads" in function.stdout - config = Docker.run('cat {}'.format( WEB_CONFIG[os])).stdout - for expected_line in CONFIG_LINES[os]: - assert re.search(expected_line, config) != None + config = Docker.run('cat {}'.format(WEB_CONFIG)).stdout + assert re.search(CONFIG_LINE, config) != None # grep fails to find any of the old address w/o port assert Docker.run('grep -rq "://127.0.0.1/" /var/www/html/').rc == 1 assert Docker.run('grep -rq "://pi.hole/" /var/www/html/').rc == 1 @@ -121,11 +120,11 @@ expected_debian_lines = [ '"ServerIP" => "127.0.0.1"', '"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"' ] -@pytest.mark.parametrize('os,expected_lines,repeat_function', [ - ('debian', expected_debian_lines, 1), - ('debian', expected_debian_lines, 2) +@pytest.mark.parametrize('expected_lines,repeat_function', [ + (expected_debian_lines, 1), + (expected_debian_lines, 2) ]) -def test_debian_setup_php_env(Docker, os, expected_lines, repeat_function): +def test_debian_setup_php_env(Docker, expected_lines, repeat_function): ''' confirm all expected output is there and nothing else ''' stdout = '' for i in range(repeat_function): From 65ecba6705a5c73c6b19196a9fdbad9ca3b2fbc4 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 14:24:44 -0500 Subject: [PATCH 20/39] updated script for new names Signed-off-by: Adam Hill --- deploy_arm.sh => deploy_docker.sh | 37 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) rename deploy_arm.sh => deploy_docker.sh (55%) diff --git a/deploy_arm.sh b/deploy_docker.sh similarity index 55% rename from deploy_arm.sh rename to deploy_docker.sh index 0803274..f2d4124 100755 --- a/deploy_arm.sh +++ b/deploy_docker.sh @@ -17,38 +17,37 @@ branch="$(parse_git_branch)" version="${version:-unset}" dry="${dry}" -if [[ -n "$dry" ]] ; then dry='echo ' ; fi +if [[ -n "$dry" ]]; then dry='echo '; fi if [[ "$version" == 'unset' ]]; then - version="$branch" if [[ "$branch" == "master" ]]; then echo "Version number var is unset and master branch needs a version...pass in \$version variable!" exit 1 - else if [[ "$branch" = "release/"* ]] - echo "Version number is being taken from this release branch" + elif [[ "$branch" = "release/"* ]]; then version="$(echo $branch | grep -Po 'v[\d.-]')" + echo "Version number is being taken from this release branch $version" + else + version="$branch" + remoteimg="${namespace}/${localimg}-dev" + echo "Using the branch ($branch) for deployed image version since not passed in" fi - echo "Using the branch ($branch) for deployed image version since not passed in" fi echo "# DEPLOYING:" echo "version: $version" echo "branch: $branch" [[ -n "$dry" ]] && echo "DRY RUN: $dry" -echo "Example tagging: docker tag $localimg:$tag $remoteimg:${version}_${tag}" -echo +echo "Example tagging: docker tag $localimg:$tag $remoteimg:${version}_amd64" $dry ./Dockerfile.py -if [[ "$branch" == "master" ]] || [[ "$branch" = "release/"* ]] ; then - # ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole - # for tag in debian_armhf debian_aarch64 debian_armel; do - for tag in amd64 armhf aarch64; do - # Verison specific tags for ongoing history - $dry docker tag $localimg:$tag $remoteimg:${version}_${tag} - $dry docker push pihole/pihole-multiarch:${version}_${tag} - # Floating latest tags - $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag} - $dry docker push pihole/pihole-multiarch:${tag} - done -fi +# ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole +# for tag in debian_armhf debian_aarch64 debian_armel; do +for tag in amd64 armhf aarch64; do + # Verison specific tags for ongoing history + $dry docker tag $localimg:$tag $remoteimg:${version}_${tag} + $dry docker push pihole/pihole-multiarch:${version}_${tag} + # Floating latest tags + $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag} + $dry docker push pihole/pihole-multiarch:${tag} +done From a4296416b0a58a40f4c2dfe37c14ca821174d933 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 14:28:27 -0500 Subject: [PATCH 21/39] readme updates Signed-off-by: Adam Hill --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 746f009..d03791a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ ## Overview -A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 ~~and ARM~~ container with [Pi-hole](https://pi-hole.net) functionality. +#### Renamed from `diginc/pi-hole` to `pihole/pihole` -1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv6l/ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. +A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality. + +1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. 2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command 3) Enjoy! @@ -115,18 +117,19 @@ Latest version of ARM64-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ + ## Upgrading, Persistence, and Customizations The standard pi-hole customization abilities apply to this docker, but with docker twists such as using docker volume mounts to map host stored file configurations over the container defaults. Volumes are also important to persist the configuration in case you have removed the pi-hole container which is a typical docker upgrade pattern. ### Upgrading -`pihole -up` is disabled. Upgrade the docker way instead, please. Long-living docker containers are not the docker way. +`pihole -up` is disabled. Upgrade the docker way instead, please. Long-living docker containers are not the docker way since they aim to be portable and reproducible, why not re-create them often! Just to prove you can. 1. Download the latest version of the image: `docker pull pihole/pihole` 2. Throw away your container: `docker rm -f pihole` From 1f49971046c77b5b2e6d3a53a59c96664d270910 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 14:34:26 -0500 Subject: [PATCH 22/39] multiarch reference removed Signed-off-by: Adam Hill --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d03791a..7434b56 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality. 1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. -2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole-multiarch:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command +2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command 3) Enjoy! [![Build Status](https://api.travis-ci.org/pihole/docker-pi-hole.svg?branch=master)](https://travis-ci.org/pihole/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) @@ -107,18 +107,18 @@ The primary docker tags / versions are explained in the following table. [Click This version of the docker aims to be as close to a standard pi-hole installation by using the recommended base OS and the exact configs and scripts (minimally modified to get them working). This enables fast updating when an update comes from pi-hole. -### `pihole/pihole-multiarch:v4.0_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:v4.0_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole:v4.0_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARMv7-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ -### `pihole/pihole-multiarch:v4.0_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole-multiarch:v4.0_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole:v4.0_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") Latest version of ARM64-compatible pihole image https://hub.docker.com/r/pihole/pihole-multiarch/tags/ ## Upgrading, Persistence, and Customizations -The standard pi-hole customization abilities apply to this docker, but with docker twists such as using docker volume mounts to map host stored file configurations over the container defaults. Volumes are also important to persist the configuration in case you have removed the pi-hole container which is a typical docker upgrade pattern. +The standard Pi-hole customization abilities apply to this docker, but with docker twists such as using docker volume mounts to map host stored file configurations over the container defaults. Volumes are also important to persist the configuration in case you have removed the Pi-hole container which is a typical docker upgrade pattern. ### Upgrading @@ -142,7 +142,7 @@ Why is this style of upgrading good? A couple reasons: Everyone is starting fro ### Pihole features -Here are some relevant wiki pages from [pi-hole's documentation](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). The web interface or command line tools can be used to implement changes to pihole. +Here are some relevant wiki pages from [Pi-hole's documentation](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). The web interface or command line tools can be used to implement changes to pihole. We install all pihole utilities so the the built in [pihole commands](https://discourse.pi-hole.net/t/the-pihole-command-with-examples/738) will work via `docker exec ` like so: @@ -152,7 +152,7 @@ We install all pihole utilities so the the built in [pihole commands](https://di ### Customizations -The webserver and DNS service inside the container can be customized if necessary. Any configuration files you volume mount into `/etc/dnsmasq.d/` will be loaded by dnsmasq when the container starts or restarts or if you need to modify the pi-hole config it is located at `/etc/dnsmasq.d/01-pihole.conf`. The docker start scripts runs a config test prior to starting so it will tell you about any errors in the docker log. +The webserver and DNS service inside the container can be customized if necessary. Any configuration files you volume mount into `/etc/dnsmasq.d/` will be loaded by dnsmasq when the container starts or restarts or if you need to modify the Pi-hole config it is located at `/etc/dnsmasq.d/01-pihole.conf`. The docker start scripts runs a config test prior to starting so it will tell you about any errors in the docker log. Similarly for the webserver you can customize configs in /etc/lighttpd @@ -176,4 +176,4 @@ Development image tags coming soon # User Feedback -Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-Hole questions are best answered on their [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on there if it's a docker and you're not sure if it's docker related. +Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on their [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on there if it's a docker and you're not sure if it's docker related. From c8d7abed1b20a15032f06477751ebab1e17a7767 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 14:52:08 -0500 Subject: [PATCH 25/39] image, theirs=ours, dockers=docker containers Signed-off-by: Adam Hill --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 521cd61..c8f0180 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## Overview +[![Pi-hole logo](https://pi-hole.github.io/graphics/Vortex/Vortex_with_text.png)] + #### Renamed from `diginc/pi-hole` to `pihole/pihole` A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality. @@ -16,7 +18,7 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 [DockerCloud](https://store.docker.com/community/images/pihole/pihole) automatically builds the latest docker-pi-hole changes into images which can easily be pulled and ran with a simple `docker run` command. Changes and updates under development or testing can be found in the [dev tags](#development) section. -One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or dockers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/pihole/docker-pi-hole/blob/master/docker_run.sh) or summarized here: +One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or docker containers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/pihole/docker-pi-hole/blob/master/docker_run.sh) or summarized here: ``` IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 @@ -176,4 +178,4 @@ Development image tags coming soon # User Feedback -Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on their [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on there if it's a docker and you're not sure if it's docker related. +Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on our [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on the forums if it's a docker container and you're not sure if it's docker related. From 3c135774d327c00b1ecf442bccf78ffee57111bf Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 14:55:08 -0500 Subject: [PATCH 26/39] image to html the same as main repo's Signed-off-by: Adam Hill --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8f0180..6163c85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ## Overview -[![Pi-hole logo](https://pi-hole.github.io/graphics/Vortex/Vortex_with_text.png)] +

+Pi-hole
+

#### Renamed from `diginc/pi-hole` to `pihole/pihole` From df63b3ee1292f3d8f386ecc83bc10e086de053be Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 15:04:35 -0500 Subject: [PATCH 27/39] image to top, links fix, better writing for 443 sinkhole Signed-off-by: Adam Hill --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6163c85..b75d909 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -## Overview -

Pi-hole

+## Overview + #### Renamed from `diginc/pi-hole` to `pihole/pihole` A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality. @@ -20,7 +20,7 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 [DockerCloud](https://store.docker.com/community/images/pihole/pihole) automatically builds the latest docker-pi-hole changes into images which can easily be pulled and ran with a simple `docker run` command. Changes and updates under development or testing can be found in the [dev tags](#development) section. -One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or docker containers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/pihole/docker-pi-hole/blob/master/docker_run.sh) or summarized here: +One crucial thing to know before starting is this container needs port 53 and port 80, two very popular ports that may conflict with existing applications. If you have no other services or docker containers using port 53/80 (if you do, keep reading below for a reverse proxy example), the minimum arguments required to run this container are in the script [docker_run.sh](https://github.com/pi-hole/docker-pi-hole/blob/master/docker_run.sh) or summarized here: ``` IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 @@ -50,7 +50,7 @@ docker logs pihole 2> /dev/null | grep 'password:' **This is just an example and might need changing.** Volumes are stored in the directory `$DOCKER_CONFIGS` and are recommended for persisting data across docker re-creations for updating images. As mentioned on line 2, the auto `IP_LOOKUP` variable may not work for VPN tunnel interfaces. -Two recently added ports to the `docker run` and `docker-compose` examples are port 67 and 443. Port 67 is for users who wish to have Pi-hole run a DHCP server. Port 443 is to provide a sinkhole for ads that use SSL. Unlike port 80, the Pi-hole blockpage is not advertised over 443/SSL instead docker forwards 443 to nothing, and this helps get a REJECT back to your browser fast, preventing slowdowns from SSL ads commonly seen in the past. An alternative is instead of binding port 443 is blocking it by the firewall of the docker host, e.g. with `sudo ufw reject https`. +Two recently added ports to the `docker run` and `docker-compose` examples are port 67 and 443. Port 67 is for users who wish to have Pi-hole run a DHCP server. Port 443 is to provide a sinkhole for ads that use SSL. If only port 80 is used, then blocked HTTPS queries will fail to connect to port 443 and may cause long loading times. An alternative is instead of binding port 443 is blocking it by the firewall of the docker host, e.g. with `sudo ufw reject https`. **Automatic Ad List Updates** - since the 3.0+ release, `cron` is baked into the container and will grab the newest versions of your lists and flush your logs. **Set your TZ** environment variable to make sure the midnight log rotation syncs up with your timezone's midnight. @@ -83,7 +83,7 @@ Here is a rundown of the other arguments passed into the example `docker run`: | `--net=host`
*Optional* | Alternative to `-p :` arguments (Cannot be used at same time as -p) if you don't run any other web application | `--cap-add=NET_ADMIN`
*Optional* | If you're forwarding port 67 you will also needs this for DHCP to work. (DHCP Reportedly works, I have not used however) -If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I have [example docker-compose.yml files](https://github.com/pihole/docker-pi-hole/blob/master/doco-example.yml) in github which I think are a nicer way to represent such long run commands. +If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I have [example docker-compose.yml files](https://github.com/pi-hole/docker-pi-hole/blob/master/doco-example.yml) in github which I think are a nicer way to represent such long run commands. ## Tips and Tricks @@ -97,15 +97,15 @@ If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I * Don't forget to stop your services from auto-starting again after you reboot * Port 80 is highly recommended because if you have another site/service using port 80 by default then the ads may not transform into blank ads correctly. To make sure docker-pi-hole plays nicely with an existing webserver you run you'll probably need a reverse proxy webserver config if you don't have one already. Pi-hole must be the default web app on the proxy e.g. if you go to your host by IP instead of domain then Pi-hole is served out instead of any other sites hosted by the proxy. This is the '[default_server](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)' in nginx or ['_default_' virtual host](https://httpd.apache.org/docs/2.4/vhosts/examples.html#default) in Apache and is taken advantage of so any undefined ad domain can be directed to your webserver and get a 'blocked' response instead of ads. * You can still map other ports to Pi-hole port 80 using docker's port forwarding like this `-p 8080:80`, but again the ads won't render properly. Changing the inner port 80 shouldn't be required unless you run docker host networking mode. - * [Here is an example of running with jwilder/proxy](https://github.com/pihole/docker-pi-hole/blob/master/jwilder-proxy-example-doco.yml) (an nginx auto-configuring docker reverse proxy for docker) on my port 80 with Pi-hole on another port. Pi-hole needs to be `DEFAULT_HOST` env in jwilder/proxy and you need to set the matching `VIRTUAL_HOST` for the Pi-hole's container. Please read jwilder/proxy readme for more info if you have trouble. I tested this basic example which is based off what I run. + * [Here is an example of running with jwilder/proxy](https://github.com/pi-hole/docker-pi-hole/blob/master/jwilder-proxy-example-doco.yml) (an nginx auto-configuring docker reverse proxy for docker) on my port 80 with Pi-hole on another port. Pi-hole needs to be `DEFAULT_HOST` env in jwilder/proxy and you need to set the matching `VIRTUAL_HOST` for the Pi-hole's container. Please read jwilder/proxy readme for more info if you have trouble. I tested this basic example which is based off what I run. ## Docker tags and versioning -The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/pihole/docker-pi-hole/releases). +The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/pi-hole/docker-pi-hole/releases). | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | -| `latest` / `v4.0` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/master/Dockerfile_amd64) | +| `latest` / `v4.0` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pi-hole/docker-pi-hole/blob/master/Dockerfile_amd64) | ### `pihole/pihole:latest` [![](https://images.microbadger.com/badges/image/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/version/pihole/pihole:latest.svg)](https://microbadger.com/images/pihole/pihole "Get your own version badge on microbadger.com") @@ -144,7 +144,7 @@ The standard Pi-hole customization abilities apply to this docker, but with dock Why is this style of upgrading good? A couple reasons: Everyone is starting from the same base image which has been tested to know it works. No worrying about upgrading from A to B, B to C, or A to C is required when rolling out updates, it reducing complexity, and simply allows a 'fresh start' every time while preserving customizations with volumes. Basically I'm encouraging [phoenix servers](https://www.google.com/?q=phoenix+servers) principles for your containers. -### Pihole features +### Pi-hole features Here are some relevant wiki pages from [Pi-hole's documentation](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). The web interface or command line tools can be used to implement changes to pihole. @@ -175,9 +175,9 @@ Development image tags coming soon | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | -| `v4.0_dev` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pihole/docker-pi-hole/blob/dev/Dockerfile_amd64) | +| `v4.0_dev` | x86 | Debian x86 image, container running lighttpd and dnsmasq | [Dockerfile](https://github.com/pi-hole/docker-pi-hole/blob/dev/Dockerfile_amd64) | --> # User Feedback -Please report issues on the [GitHub project](https://github.com/pihole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on our [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on the forums if it's a docker container and you're not sure if it's docker related. +Please report issues on the [GitHub project](https://github.com/pi-hole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on our [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on the forums if it's a docker container and you're not sure if it's docker related. From 1c063a66197c6b01c880d5a59e7e6e4dbe70d590 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 15:08:24 -0500 Subject: [PATCH 28/39] change password interactively to avoid leaving bash history Signed-off-by: Adam Hill --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b75d909..3a3746d 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I * A good way to test things are working right is by loading this page: [http://pi.hole/admin/](http://pi.hole/admin/) * [How do I set or reset the Web interface Password?](https://discourse.pi-hole.net/t/how-do-i-set-or-reset-the-web-interface-password/1328) - * `docker exec pihole_container_name pihole -a -p supersecurepassword` + * `docker exec -it pihole_container_name pihole -a -p` - then enter your password into the prompt * Port conflicts? Stop your server's existing DNS / Web services. * Ubuntu users especially may need to shut off dns on your docker server so it can run in the container on port 53 * 17.04 and later should disable dnsmasq. From 5ee2cc947c90a2f2586dbc0ee06e2ceda46299cf Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 15:17:06 -0500 Subject: [PATCH 29/39] Better writing for second half of 443 sinkhold section Signed-off-by: Adam Hill --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a3746d..2d219bb 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ docker logs pihole 2> /dev/null | grep 'password:' **This is just an example and might need changing.** Volumes are stored in the directory `$DOCKER_CONFIGS` and are recommended for persisting data across docker re-creations for updating images. As mentioned on line 2, the auto `IP_LOOKUP` variable may not work for VPN tunnel interfaces. -Two recently added ports to the `docker run` and `docker-compose` examples are port 67 and 443. Port 67 is for users who wish to have Pi-hole run a DHCP server. Port 443 is to provide a sinkhole for ads that use SSL. If only port 80 is used, then blocked HTTPS queries will fail to connect to port 443 and may cause long loading times. An alternative is instead of binding port 443 is blocking it by the firewall of the docker host, e.g. with `sudo ufw reject https`. +Two recently added ports to the `docker run` and `docker-compose` examples are port 67 and 443. Port 67 is for users who wish to have Pi-hole run a DHCP server. Port 443 is to provide a sinkhole for ads that use SSL. If only port 80 is used, then blocked HTTPS queries will fail to connect to port 443 and may cause long loading times. Rejecting 443 on your firewall can also serve this same purpose. Ubuntu firewall example: `sudo ufw reject https` **Automatic Ad List Updates** - since the 3.0+ release, `cron` is baked into the container and will grab the newest versions of your lists and flush your logs. **Set your TZ** environment variable to make sure the midnight log rotation syncs up with your timezone's midnight. From 119999be716d23f69a16b410006f733728570e91 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 15:58:05 -0500 Subject: [PATCH 30/39] Fix web password corruption Signed-off-by: Adam Hill --- bash_functions.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 9d28f20..2d5a5b7 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -23,7 +23,9 @@ prepare_configs() { if [[ -e "${setupVars}" ]]; then # update the variables in the file sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}" + local USERWEBPASSWORD="${WEBPASSWORD}" . "${setupVars}" + export WEBPASSWORD="${USERWEBPASSWORD}" fi # echo the information to the user { @@ -223,25 +225,23 @@ setup_web_port() { } setup_web_password() { - #if ! grep -q 'WEBPASSWORD' ${setupVars}; then - if [ -z "${WEBPASSWORD+x}" ] ; then - # Not set at all, give the user a random pass - WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) - echo "Assigning random password: $WEBPASSWORD" - fi; - # Turn bash debug on while setting up password (to print it) - set -x - if [[ "$WEBPASSWORD" == "" ]] ; then - echo "" | pihole -a -p - else - pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" - fi - if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then - # Turn bash debug back off after print password setup - # (subshell to null hides printing output) - { set +x; } 2>/dev/null - fi - #fi + if [ -z "${WEBPASSWORD+x}" ]; then + # Not set at all, give the user a random pass + WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) + echo "Assigning random password: $WEBPASSWORD" + fi; + # Turn bash debug on while setting up password (to print it) + set -x + if [[ "$WEBPASSWORD" == "" ]]; then + echo "" | pihole -a -p + else + pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" + fi + if [ "${PH_VERBOSE:-0}" -gt 0 ]; then + # Turn bash debug back off after print password setup + # (subshell to null hides printing output) + { set +x; } 2>/dev/null + fi } setup_ipv4_ipv6() { From 20e8ce208cbf7f784950035fd97ed34d9aa325ff Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 16:19:11 -0500 Subject: [PATCH 31/39] quick fix to web password regression, probably not greatest fix but it works Signed-off-by: Adam Hill --- bash_functions.sh | 9 +++++---- start.sh | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 2d5a5b7..8ae7ca9 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -25,7 +25,8 @@ prepare_configs() { sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}" local USERWEBPASSWORD="${WEBPASSWORD}" . "${setupVars}" - export WEBPASSWORD="${USERWEBPASSWORD}" + # Stash and pop the user password to avoid setting the password to the hashed setupVar variable + WEBPASSWORD="${USERWEBPASSWORD}" fi # echo the information to the user { @@ -225,19 +226,19 @@ setup_web_port() { } setup_web_password() { - if [ -z "${WEBPASSWORD+x}" ]; then + if [ -z "${WEBPASSWORD+x}" ] ; then # Not set at all, give the user a random pass WEBPASSWORD=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) echo "Assigning random password: $WEBPASSWORD" fi; # Turn bash debug on while setting up password (to print it) set -x - if [[ "$WEBPASSWORD" == "" ]]; then + if [[ "$WEBPASSWORD" == "" ]] ; then echo "" | pihole -a -p else pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" fi - if [ "${PH_VERBOSE:-0}" -gt 0 ]; then + if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then # Turn bash debug back off after print password setup # (subshell to null hides printing output) { set +x; } 2>/dev/null diff --git a/start.sh b/start.sh index 460e3e1..a69fbd6 100755 --- a/start.sh +++ b/start.sh @@ -12,8 +12,8 @@ export DNS1 export DNS2 export INTERFACE export IPv6 -export WEBPASSWORD export WEB_PORT +export PLAINWEBPASSWORD="$WEBPASSWORD" export adlistFile='/etc/pihole/adlists.list' @@ -31,7 +31,7 @@ prepare_configs change_setting "IPV4_ADDRESS" "$ServerIP" change_setting "IPV6_ADDRESS" "$ServerIPv6" setup_web_port "$WEB_PORT" -setup_web_password "$WEBPASSWORD" +setup_web_password "$PLAINWEBPASSWORD" setup_dnsmasq "$DNS1" "$DNS2" "$INTERFACE" setup_php_env setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME" From 5cc28d769a37fdc2691fff40a9040e2e9c40e7e0 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 19:33:45 -0500 Subject: [PATCH 32/39] Updated deploy script (still needs work), fixed dead link Signed-off-by: Adam Hill --- Dockerfile_aarch64 | 16 ++++++++-------- Dockerfile_armel | 16 ++++++++-------- Dockerfile_armhf | 16 ++++++++-------- README.md | 2 +- deploy_docker.sh | 18 +++++++++++------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Dockerfile_aarch64 b/Dockerfile_aarch64 index 8dd1bd8..621e8dc 100644 --- a/Dockerfile_aarch64 +++ b/Dockerfile_aarch64 @@ -1,13 +1,5 @@ FROM multiarch/debian-debootstrap:arm64-stretch-slim -LABEL image="pihole/pihole:v4.0_aarch64" -LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/pi-hole/docker-pi-hole" - -ENV VERSION v4.0 -ENV ARCH aarch64 -ENV PATH /opt/pihole:${PATH} - COPY install.sh /usr/local/bin/docker-install.sh ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-aarch64.tar.gz @@ -44,6 +36,14 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 ENV FTL_CMD no-daemon +ENV VERSION v4.0 +ENV ARCH aarch64 +ENV PATH /opt/pihole:${PATH} + +LABEL image="pihole/pihole:v4.0_aarch64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" + HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_armel b/Dockerfile_armel index a2999e8..17eb271 100644 --- a/Dockerfile_armel +++ b/Dockerfile_armel @@ -1,13 +1,5 @@ FROM multiarch/debian-debootstrap:armel-stretch-slim -LABEL image="pihole/pihole:v4.0_armel" -LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/pi-hole/docker-pi-hole" - -ENV VERSION v4.0 -ENV ARCH armel -ENV PATH /opt/pihole:${PATH} - COPY install.sh /usr/local/bin/docker-install.sh ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-arm.tar.gz @@ -44,6 +36,14 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 ENV FTL_CMD no-daemon +ENV VERSION v4.0 +ENV ARCH armel +ENV PATH /opt/pihole:${PATH} + +LABEL image="pihole/pihole:v4.0_armel" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" + HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_armhf b/Dockerfile_armhf index e38fe0d..976e433 100644 --- a/Dockerfile_armhf +++ b/Dockerfile_armhf @@ -1,13 +1,5 @@ FROM multiarch/debian-debootstrap:armhf-stretch-slim -LABEL image="pihole/pihole:v4.0_armhf" -LABEL maintainer="adam@diginc.us" -LABEL url="https://www.github.com/pi-hole/docker-pi-hole" - -ENV VERSION v4.0 -ENV ARCH armhf -ENV PATH /opt/pihole:${PATH} - COPY install.sh /usr/local/bin/docker-install.sh ENV PIHOLE_INSTALL /root/ph_install.sh ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.4.0/s6-overlay-armhf.tar.gz @@ -44,6 +36,14 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 ENV FTL_CMD no-daemon +ENV VERSION v4.0 +ENV ARCH armhf +ENV PATH /opt/pihole:${PATH} + +LABEL image="pihole/pihole:v4.0_armhf" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/pi-hole/docker-pi-hole" + HEALTHCHECK CMD dig @127.0.0.1 pi.hole || exit 1 SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/README.md b/README.md index 2d219bb..70505cb 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ Similarly for the webserver you can customize configs in /etc/lighttpd ### Systemd init script -As long as your docker system service auto starts on boot and you run your container with `--restart=unless-stopped` your container should always start on boot and restart on crashes. If you prefer to have your docker container run as a systemd service instead, add the file [pihole.service](https://raw.githubusercontent.com/pihole/docker-pi-hole/master/pihole.service) to "/etc/systemd/system"; customize whatever your container name is and remove `--restart=unless-stopped` from your docker run. Then after you have initially created the docker container using the docker run command above, you can control it with "systemctl start pihole" or "systemctl stop pihole" (instead of `docker start`/`docker stop`). You can also enable it to auto-start on boot with "systemctl enable pihole" (as opposed to `--restart=unless-stopped` and making sure docker service auto-starts on boot). +As long as your docker system service auto starts on boot and you run your container with `--restart=unless-stopped` your container should always start on boot and restart on crashes. If you prefer to have your docker container run as a systemd service instead, add the file [pihole.service](https://raw.githubusercontent.com/pi-hole/docker-pi-hole/master/pihole.service) to "/etc/systemd/system"; customize whatever your container name is and remove `--restart=unless-stopped` from your docker run. Then after you have initially created the docker container using the docker run command above, you can control it with "systemctl start pihole" or "systemctl stop pihole" (instead of `docker start`/`docker stop`). You can also enable it to auto-start on boot with "systemctl enable pihole" (as opposed to `--restart=unless-stopped` and making sure docker service auto-starts on boot). NOTE: After initial run you may need to manually stop the docker container with "docker stop pihole" before the systemctl can start controlling the container. diff --git a/deploy_docker.sh b/deploy_docker.sh index f2d4124..0e3713a 100755 --- a/deploy_docker.sh +++ b/deploy_docker.sh @@ -16,6 +16,7 @@ remoteimg="$namespace/$localimg" branch="$(parse_git_branch)" version="${version:-unset}" dry="${dry}" +latest="${latest:-false}" # true as shell env var to deploy latest if [[ -n "$dry" ]]; then dry='echo '; fi @@ -24,7 +25,7 @@ if [[ "$version" == 'unset' ]]; then echo "Version number var is unset and master branch needs a version...pass in \$version variable!" exit 1 elif [[ "$branch" = "release/"* ]]; then - version="$(echo $branch | grep -Po 'v[\d.-]')" + version="$(echo $branch | grep -Po 'v[\d\.-]*')" echo "Version number is being taken from this release branch $version" else version="$branch" @@ -39,15 +40,18 @@ echo "branch: $branch" [[ -n "$dry" ]] && echo "DRY RUN: $dry" echo "Example tagging: docker tag $localimg:$tag $remoteimg:${version}_amd64" -$dry ./Dockerfile.py +$dry ./Dockerfile.py --arch=amd64 --arch=armhf --arch=aarch64 # ARMv6/armel doesn't have a FTL binary for v4.0 pi-hole # for tag in debian_armhf debian_aarch64 debian_armel; do for tag in amd64 armhf aarch64; do # Verison specific tags for ongoing history - $dry docker tag $localimg:$tag $remoteimg:${version}_${tag} - $dry docker push pihole/pihole-multiarch:${version}_${tag} - # Floating latest tags - $dry docker tag pi-hole-multiarch:$tag pihole/pihole-multiarch:${tag} - $dry docker push pihole/pihole-multiarch:${tag} + $dry docker tag $localimg:v4.0_$tag $remoteimg:${version}_${tag} + $dry docker push pihole/pihole:${version}_${tag} + # Floating latest tags (Conditionalize these to master?) + if [[ "$tag" == 'amd64' ]] && [[ "$branch" == 'master' || "$latest" == 'true' ]] ; then + # Latest tag should become a manifest for multiple architectures, not just amd64! + $dry docker tag pi-hole:v4.0_amd64 pihole/pihole:latest + $dry docker push pihole/pihole:latest + fi; done From c56385ad4964eb6fad28e8d695a4458902bff799 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 19:43:05 -0500 Subject: [PATCH 33/39] remove multiarch and comments from readme (dockerhub does not high comments) Signed-off-by: Adam Hill --- README.md | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 70505cb..b871801 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality. 1) Install docker for your [x86-64 system](https://www.docker.com/community-edition) or [ARMv7 system](https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/) using those links. -2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)) in the below `docker run` command +2) Use the appropriate tag (x86 can use default tag, ARM users need to use images from [pihole/pihole:v4.0_armhf](https://store.docker.com/community/images/pihole/pihole/tags)) in the below `docker run` command 3) Enjoy! [![Build Status](https://api.travis-ci.org/pi-hole/docker-pi-hole.svg?branch=master)](https://travis-ci.org/pi-hole/docker-pi-hole) [![Docker Stars](https://img.shields.io/docker/stars/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) [![Docker Pulls](https://img.shields.io/docker/pulls/pihole/pihole.svg?maxAge=604800)](https://store.docker.com/community/images/pihole/pihole) @@ -101,7 +101,7 @@ If you're a fan of [docker-compose](https://docs.docker.com/compose/install/) I ## Docker tags and versioning -The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole-multiarch/tags)), I also try to tag with the specific version of Pi-hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/pi-hole/docker-pi-hole/releases). +The primary docker tags / versions are explained in the following table. [Click here to see the full list of x86 tags](https://store.docker.com/community/images/pihole/pihole/tags) ([arm tags are here](https://store.docker.com/community/images/pihole/pihole/tags)), I also try to tag with the specific version of Pi-hole Core for version archival purposes, the web version that comes with the core releases should be in the [GitHub Release notes](https://github.com/pi-hole/docker-pi-hole/releases). | tag | architecture | description | Dockerfile | | --- | ------------ | ----------- | ---------- | @@ -111,22 +111,16 @@ The primary docker tags / versions are explained in the following table. [Click This version of the docker aims to be as close to a standard Pi-hole installation by using the recommended base OS and the exact configs and scripts (minimally modified to get them working). This enables fast updating when an update comes from Pi-hole. -### `pihole/pihole:v4.0_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_armhf.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole:v4.0_armhf` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_armhf.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") Latest version of ARMv7-compatible pihole image -https://hub.docker.com/r/pihole/pihole-multiarch/tags/ +https://hub.docker.com/r/pihole/pihole/tags/ -### `pihole/pihole:v4.0_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_aarch64.svg)](https://microbadger.com/images/pihole/pihole-multiarch "Get your own image badge on microbadger.com") +### `pihole/pihole:v4.0_aarch64` [![](https://images.microbadger.com/badges/image/pihole/pihole:v4.0_aarch64.svg)](https://microbadger.com/images/pihole/pihole "Get your own image badge on microbadger.com") Latest version of ARM64-compatible pihole image -https://hub.docker.com/r/pihole/pihole-multiarch/tags/ +https://hub.docker.com/r/pihole/pihole/tags/ - ## Upgrading, Persistence, and Customizations The standard Pi-hole customization abilities apply to this docker, but with docker twists such as using docker volume mounts to map host stored file configurations over the container defaults. Volumes are also important to persist the configuration in case you have removed the Pi-hole container which is a typical docker upgrade pattern. @@ -170,14 +164,6 @@ NOTE: After initial run you may need to manually stop the docker container with Development image tags coming soon - - # User Feedback Please report issues on the [GitHub project](https://github.com/pi-hole/docker-pi-hole) when you suspect something docker related. Pi-hole questions are best answered on our [user forums](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). Ping me (@diginc) on the forums if it's a docker container and you're not sure if it's docker related. From 797a9213e40d66a1ad3c575057e8d96929dbd589 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sat, 4 Aug 2018 19:46:12 -0500 Subject: [PATCH 34/39] Adding helpful comment for copy paste to Dockerhub/Store Signed-off-by: Adam Hill --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b871801..36c5dfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

Pi-hole

+ ## Overview From 22ea5e77b4f96368a9e9ea530df522392b72dde3 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 5 Aug 2018 13:14:00 -0500 Subject: [PATCH 35/39] Use new v4 prod tags, scrub old dev install code Signed-off-by: Adam Hill --- install.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 8fa3c7e..50fae9a 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,13 @@ #!/bin/bash -ex mkdir -p /etc/pihole/ mkdir -p /var/run/pihole -export CORE_TAG='v3.3.1' -export WEB_TAG='v3.3' -export USE_FTLDNS_BRANCHES=true -export USE_DEVELOPMENT_BRANCHES=false +# Production tags with valid web footers +export CORE_TAG='v4.0' +export WEB_TAG='v4.0' +# Only use for pre-production / testing +export USE_CUSTOM_BRANCHES=false -if [[ $USE_FTLDNS_BRANCHES == true ]] ; then - CORE_TAG='release/v4.0' -elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then +if [[ $USE_CUSTOM_BRANCHES == true ]] ; then CORE_TAG='development' fi @@ -62,18 +61,12 @@ installLogLoc="${installLogLoc}" installPihole 2>&1 | tee "${tmpLog}" mv "${tmpLog}" / -if [[ $USE_FTLDNS_BRANCHES == true ]] ; then +if [[ $USE_CUSTOM_BRANCHES == true ]] ; then ln -s /bin/true /usr/local/bin/service echo "$CORE_TAG" | tee /etc/pihole/ftlbranch echo y | bash -x pihole checkout core $CORE_TAG echo y | bash -x pihole checkout web $CORE_TAG unlink /usr/local/bin/service -elif [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then - ln -s /bin/true /usr/local/bin/service - echo y | bash -x pihole checkout core development - echo y | bash -x pihole checkout web devel - echo y | bash -x pihole checkout ftl development - unlink /usr/local/bin/service else # Reset to our tags so version numbers get detected correctly pushd "${PI_HOLE_LOCAL_REPO}"; git reset --hard "${CORE_TAG}"; popd; From cb0fffa26fa4d9bc624e829aef6806d6288b611c Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 5 Aug 2018 13:18:57 -0500 Subject: [PATCH 36/39] disable armel(broken in 4.0 for now) --- .travis.yml | 1 - tox.ini | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c65e35..19ddc60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ env: - QEMU_VER=v2.9.1 matrix: - ARCH=amd64 - - ARCH=armel - ARCH=armhf - ARCH=aarch64 python: diff --git a/tox.ini b/tox.ini index 54ab13d..ad9cca1 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,6 @@ deps = -rrequirements.txt commands = docker run --rm --privileged multiarch/qemu-user-static:register --reset ./Dockerfile.py -v --arch amd64 pytest -vv -n 2 -k amd64 ./test/ - ./Dockerfile.py -v --skip amd64 - pytest -vv -n 2 -k armel ./test/ + ./Dockerfile.py -v --arch armhf --arch aarch64 pytest -vv -n 2 -k armhf ./test/ pytest -vv -n 2 -k aarch64 ./test/ From 999f02b5980b45754fe1e719f5b82ac6b375de54 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 5 Aug 2018 17:58:41 -0500 Subject: [PATCH 37/39] start of fixing race condition by not having test+s6 both run /start.sh Signed-off-by: Adam Hill --- test/conftest.py | 13 +++++++++---- test/test_start.py | 11 ++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 897e1ec..287e04c 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -5,11 +5,11 @@ check_output = testinfra.get_backend( "local://" ).get_module("Command").check_output -def DockerGeneric(request, args, image, cmd): +def DockerGeneric(request, args, image, cmd, entrypoint=''): assert 'docker' in check_output('id'), "Are you in the docker group?" if 'pihole' in image: args += " --dns 127.0.0.1 -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\"" - docker_run = "docker run -d {} {} {}".format(args, image, cmd) + docker_run = "docker run -d {args} {entry} {image} {cmd}".format(args, image, cmd) print docker_run docker_id = check_output(docker_run) @@ -37,10 +37,11 @@ def DockerGeneric(request, args, image, cmd): docker_container.run = funcType(run_bash, docker_container, testinfra.backend.docker.DockerBackend) return docker_container + @pytest.fixture -def Docker(request, args, image, cmd): +def Docker(request, args, image, cmd, entrypoint): ''' One-off Docker container run ''' - return DockerGeneric(request, args, image, cmd) + return DockerGeneric(request, args, image, cmd, entrypoint) @pytest.fixture(scope='module') def DockerPersist(request, persist_args, persist_image, persist_cmd, Dig): @@ -51,6 +52,10 @@ def DockerPersist(request, persist_args, persist_image, persist_cmd, Dig): persistent_container.dig = Dig(persistent_container.id) return persistent_container +@pytest.fixture +def entrypoint(): + return '' + @pytest.fixture() def args(request): return '-e ServerIP="127.0.0.1" -e ServerIPv6="::1"' diff --git a/test/test_start.py b/test/test_start.py index a5ef6a0..fa4ae97 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -4,15 +4,7 @@ import time ''' Note, testinfra builtins don't seem fully compatible with docker containers (esp. musl based OSs) stripped down nature ''' -def test_pihole_default_run_command(Docker, tag): - expected_proc = '/sbin/tini -- /start.sh' - pgrep = 'pgrep -f "{}" | wc -l || echo 0'.format(expected_proc) - find_proc = Docker.run(pgrep).stdout - if int(find_proc) < 1: - print Docker.run('ps -ef') - print "{} : {}".format(pgrep, find_proc) - assert False, '{}: Couldn\'t find proc {}'.format(tag, expected_proc) - +@pytest.mark.parametrize('entrypoint', ['--entrypoint=/bin/bash']) @pytest.mark.parametrize('args', [ '' ]) def test_ServerIP_missing_triggers_start_error(Docker): ''' When args to docker are empty start.sh exits saying ServerIP is required ''' @@ -21,6 +13,7 @@ def test_ServerIP_missing_triggers_start_error(Docker): assert start.rc == 1 assert error_msg in start.stdout +@pytest.mark.parametrize('entrypoint', ['--entrypoint=/bin/bash']) @pytest.mark.parametrize('args,error_msg,expect_rc', [ ('-e ServerIP="1.2.3.z"', "ServerIP Environment variable (1.2.3.z) doesn't appear to be a valid IPv4 address",1), ('-e ServerIP="1.2.3.4" -e ServerIPv6="1234:1234:1234:ZZZZ"', "Environment variable (1234:1234:1234:ZZZZ) doesn't appear to be a valid IPv6 address",1), From 65a1ac7f1ed9b72c861e18addd1bf35cc974b71d Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 5 Aug 2018 18:20:55 -0500 Subject: [PATCH 38/39] grab version on startup for web footer. 2 tests stablized Signed-off-by: Adam Hill --- bash_functions.sh | 3 +++ test/conftest.py | 2 +- test/test_start.py | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 8ae7ca9..2df00fc 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -1,6 +1,7 @@ #!/bin/bash prepare_configs() { + # Done in /start.sh, don't do twice PH_TEST=true . $PIHOLE_INSTALL distro_check installConfigs @@ -17,6 +18,8 @@ prepare_configs() { chown pihole:pihole /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /etc/pihole /etc/pihole/dhcp.leases /var/log/pihole.log chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log set -e + # Update version numbers + pihole updatechecker # Re-write all of the setupVars to ensure required ones are present (like QUERY_LOGGING) # If the setup variable file exists, diff --git a/test/conftest.py b/test/conftest.py index 287e04c..cb4de2b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -9,7 +9,7 @@ def DockerGeneric(request, args, image, cmd, entrypoint=''): assert 'docker' in check_output('id'), "Are you in the docker group?" if 'pihole' in image: args += " --dns 127.0.0.1 -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\"" - docker_run = "docker run -d {args} {entry} {image} {cmd}".format(args, image, cmd) + docker_run = "docker run -d {args} {entry} {image} {cmd}".format(args=args, entry=entrypoint, image=image, cmd=cmd) print docker_run docker_id = check_output(docker_run) diff --git a/test/test_start.py b/test/test_start.py index fa4ae97..9a51043 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -4,7 +4,8 @@ import time ''' Note, testinfra builtins don't seem fully compatible with docker containers (esp. musl based OSs) stripped down nature ''' -@pytest.mark.parametrize('entrypoint', ['--entrypoint=/bin/bash']) +# If the test runs /start.sh, do not let s6 run it too! Kill entrypoint to avoid race condition/duplicated execution +@pytest.mark.parametrize('entrypoint,cmd', [('--entrypoint=tail','-f /dev/null')]) @pytest.mark.parametrize('args', [ '' ]) def test_ServerIP_missing_triggers_start_error(Docker): ''' When args to docker are empty start.sh exits saying ServerIP is required ''' @@ -13,7 +14,8 @@ def test_ServerIP_missing_triggers_start_error(Docker): assert start.rc == 1 assert error_msg in start.stdout -@pytest.mark.parametrize('entrypoint', ['--entrypoint=/bin/bash']) +# If the test runs /start.sh, do not let s6 run it too! Kill entrypoint to avoid race condition/duplicated execution +@pytest.mark.parametrize('entrypoint,cmd', [('--entrypoint=tail','-f /dev/null')]) @pytest.mark.parametrize('args,error_msg,expect_rc', [ ('-e ServerIP="1.2.3.z"', "ServerIP Environment variable (1.2.3.z) doesn't appear to be a valid IPv4 address",1), ('-e ServerIP="1.2.3.4" -e ServerIPv6="1234:1234:1234:ZZZZ"', "Environment variable (1234:1234:1234:ZZZZ) doesn't appear to be a valid IPv6 address",1), From f8d37693edd52a129adb09d20dc7103c3be68ff4 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Sun, 5 Aug 2018 22:23:22 -0500 Subject: [PATCH 39/39] Fix regex writing for web, fix deploying latest Signed-off-by: Adam Hill --- bash_functions.sh | 4 +++- deploy_docker.sh | 2 +- test/conftest.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 2df00fc..b1c0475 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -11,7 +11,9 @@ prepare_configs() { # Re-apply perms from basic-install over any volume mounts that may be present (or not) chown pihole:root /etc/lighttpd chown pihole:pihole "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" "/var/log/pihole" "${regexFile}" - chmod 644 "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" "${regexFile}" + chmod 644 "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" + # not sure why pihole:pihole user/group write perms are not enough for web to write...dirty fix: + chmod 777 "${regexFile}" touch /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log chown pihole:pihole /var/run/pihole /var/log/pihole test -f /var/run/pihole/FTL.sock && rm /var/run/pihole/FTL.sock diff --git a/deploy_docker.sh b/deploy_docker.sh index 0e3713a..79b4397 100755 --- a/deploy_docker.sh +++ b/deploy_docker.sh @@ -51,7 +51,7 @@ for tag in amd64 armhf aarch64; do # Floating latest tags (Conditionalize these to master?) if [[ "$tag" == 'amd64' ]] && [[ "$branch" == 'master' || "$latest" == 'true' ]] ; then # Latest tag should become a manifest for multiple architectures, not just amd64! - $dry docker tag pi-hole:v4.0_amd64 pihole/pihole:latest + $dry docker tag pihole:v4.0_amd64 pihole/pihole:latest $dry docker push pihole/pihole:latest fi; done diff --git a/test/conftest.py b/test/conftest.py index cb4de2b..9a0ed98 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -158,5 +158,5 @@ Persistent Docker container for testing service post start.sh def RunningPiHole(DockerPersist, Slow, persist_webserver): ''' Persist a fully started docker-pi-hole to help speed up subsequent tests ''' Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0) - Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver) ).rc == 0) + Slow(lambda: DockerPersist.run('pgrep lighttpd').rc == 0) return DockerPersist