From aac93cd6f8f79836849a754b7ada5afc624a1f57 Mon Sep 17 00:00:00 2001 From: Lyrex Date: Tue, 5 Sep 2017 20:35:49 +0200 Subject: [PATCH 01/12] Fix hostname bug on block page --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index e3211ab..9c6ed0d 100755 --- a/install.sh +++ b/install.sh @@ -76,6 +76,9 @@ installPihole | tee "${tmpLog}" sed -i 's/readonly //g' /opt/pihole/webpage.sh if [[ "$IMAGE" == 'alpine' ]] ; then cp /etc/.pihole/advanced/pihole.cron /etc/crontabs/pihole + + # Fix hostname bug on block page + sed -i "s/\(\$_SERVER\['SERVER_NAME'\]\)/\(\$_SERVER\['HTTP_HOST'\]\)/" /var/www/html/pihole/index.php fi From aee35549f5afc9e2ef1faf501582355b6b918c54 Mon Sep 17 00:00:00 2001 From: Lyrex Date: Tue, 5 Sep 2017 20:52:58 +0200 Subject: [PATCH 02/12] Reduce search pattern size and complexity --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9c6ed0d..8b838ba 100755 --- a/install.sh +++ b/install.sh @@ -77,8 +77,8 @@ sed -i 's/readonly //g' /opt/pihole/webpage.sh if [[ "$IMAGE" == 'alpine' ]] ; then cp /etc/.pihole/advanced/pihole.cron /etc/crontabs/pihole - # Fix hostname bug on block page - sed -i "s/\(\$_SERVER\['SERVER_NAME'\]\)/\(\$_SERVER\['HTTP_HOST'\]\)/" /var/www/html/pihole/index.php + # Fix hostname bug on block page + sed -i "s/\$_SERVER\['SERVER_NAME'\]/\$_SERVER\['HTTP_HOST'\]/" /var/www/html/pihole/index.php fi From 397ad13599ea27042af6792a6d72505c0633a9be Mon Sep 17 00:00:00 2001 From: Mauricio Ugaz Date: Sun, 1 Oct 2017 10:46:41 -0300 Subject: [PATCH 03/12] Alpine based images for ARM* --- alpine-arm.docker | 60 +++++++++++++++++++++++++++++++++++++++++++++ alpine-arm64.docker | 60 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 alpine-arm.docker create mode 100644 alpine-arm64.docker diff --git a/alpine-arm.docker b/alpine-arm.docker new file mode 100644 index 0000000..0d05255 --- /dev/null +++ b/alpine-arm.docker @@ -0,0 +1,60 @@ +FROM multiarch/alpine:armhf-edge +MAINTAINER adam@diginc.us + +ENV IMAGE alpine +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.19.1.1/s6-overlay-armhf.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] diff --git a/alpine-arm64.docker b/alpine-arm64.docker new file mode 100644 index 0000000..34db0af --- /dev/null +++ b/alpine-arm64.docker @@ -0,0 +1,60 @@ +FROM multiarch/alpine:aarch64-edge +MAINTAINER adam@diginc.us + +ENV IMAGE alpine +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.19.1.1/s6-overlay-aarch64.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] From ba86bc53d8be5345108477b7c480dbe4d2678d84 Mon Sep 17 00:00:00 2001 From: diginc Date: Sun, 1 Oct 2017 23:25:57 -0500 Subject: [PATCH 04/12] Generate dockerfiles for easier updating, all the variants for debian+alpine, updated s6 --- DockerfileGeneration.py | 55 ++++++++++++++++++++++++++++++++++ Dockerfile_alpine.template | 61 ++++++++++++++++++++++++++++++++++++++ Dockerfile_alpine_aarch64 | 61 ++++++++++++++++++++++++++++++++++++++ Dockerfile_alpine_amd64 | 61 ++++++++++++++++++++++++++++++++++++++ Dockerfile_alpine_armhf | 61 ++++++++++++++++++++++++++++++++++++++ Dockerfile_debian.template | 42 ++++++++++++++++++++++++++ Dockerfile_debian_aarch64 | 42 ++++++++++++++++++++++++++ Dockerfile_debian_amd64 | 42 ++++++++++++++++++++++++++ Dockerfile_debian_armhf | 42 ++++++++++++++++++++++++++ 9 files changed, 467 insertions(+) create mode 100644 DockerfileGeneration.py create mode 100644 Dockerfile_alpine.template create mode 100644 Dockerfile_alpine_aarch64 create mode 100644 Dockerfile_alpine_amd64 create mode 100644 Dockerfile_alpine_armhf create mode 100644 Dockerfile_debian.template create mode 100644 Dockerfile_debian_aarch64 create mode 100644 Dockerfile_debian_amd64 create mode 100644 Dockerfile_debian_armhf diff --git a/DockerfileGeneration.py b/DockerfileGeneration.py new file mode 100644 index 0000000..aa99ffb --- /dev/null +++ b/DockerfileGeneration.py @@ -0,0 +1,55 @@ +from jinja2 import Environment, FileSystemLoader +import os + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + +base_vars = { + 'name': 'diginc/pi-hole', + 'maintainer' : 'adam@diginc.us', + 's6_version' : 'v1.20.0.0', +} + +images = { + 'debian': [ + dict(base_vars.items() + { + 'base': 'debian:jessie', + 'arch': 'amd64' + }.items()), + dict(base_vars.items() + { + 'base': 'multiarch/debian-debootstrap:armhf-jessie-slim', + 'arch': 'armhf' + }.items()), + dict(base_vars.items() + { + 'base': 'multiarch/debian-debootstrap:arm64-jessie-slim', + 'arch': 'aarch64' + }.items()), + ], + 'alpine': [ + dict(base_vars.items() + { + 'base': 'alpine:edge', + 'arch': 'amd64' + }.items()), + dict(base_vars.items() + { + 'base': 'multiarch/alpine:armhf-edge', + 'arch': 'armhf' + }.items()), + dict(base_vars.items() + { + 'base': 'multiarch/alpine:aarch64-edge', + 'arch': 'aarch64' + }.items()) + ] +} + +def generate_dockerfiles(): + for os, archs in images.iteritems(): + for image in archs: + j2_env = Environment(loader=FileSystemLoader(THIS_DIR), + trim_blocks=True) + template = j2_env.get_template('Dockerfile_{}.template'.format(os)) + + Dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) + with open(Dockerfile, 'w') as f: + f.write(template.render(os=os, image=image)) + +if __name__ == '__main__': + generate_dockerfiles() diff --git a/Dockerfile_alpine.template b/Dockerfile_alpine.template new file mode 100644 index 0000000..a9ad43e --- /dev/null +++ b/Dockerfile_alpine.template @@ -0,0 +1,61 @@ +FROM {{ image.base }} +LABEL {{ image.maintainer }} + +ENV IMAGE {{ os }} +ENV ARCH {{ image.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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] diff --git a/Dockerfile_alpine_aarch64 b/Dockerfile_alpine_aarch64 new file mode 100644 index 0000000..0fb30a2 --- /dev/null +++ b/Dockerfile_alpine_aarch64 @@ -0,0 +1,61 @@ +FROM multiarch/alpine:aarch64-edge +LABEL adam@diginc.us + +ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_alpine_amd64 b/Dockerfile_alpine_amd64 new file mode 100644 index 0000000..8e6a202 --- /dev/null +++ b/Dockerfile_alpine_amd64 @@ -0,0 +1,61 @@ +FROM alpine:edge +LABEL adam@diginc.us + +ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_alpine_armhf b/Dockerfile_alpine_armhf new file mode 100644 index 0000000..e466ffb --- /dev/null +++ b/Dockerfile_alpine_armhf @@ -0,0 +1,61 @@ +FROM multiarch/alpine:armhf-edge +LABEL adam@diginc.us + +ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz + +RUN apk upgrade --update && \ + apk add bind-tools wget curl bash libcap && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT [ "/init" ] + +ADD s6/alpine-root / +COPY s6/service /usr/local/bin/service + +# Things installer did and fix alpine+nginx differences +ENV WEBLOGDIR /var/log/nginx +ENV PHP_CONFIG '/etc/php5/php-fpm.conf' +RUN mkdir -p /etc/pihole/ && \ + mkdir -p /var/www/html/pihole && \ + mkdir -p /var/www/html/admin/ && \ + chown nginx:nginx /var/www/html && \ + touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ + chown -R nginx:nginx ${WEBLOGDIR} && \ + sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ + sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ + chmod 775 /var/www/html && \ + touch /var/log/pihole.log && \ + chmod 644 /var/log/pihole.log && \ + chown dnsmasq:root /var/log/pihole.log && \ + sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ + setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ + cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ + echo 'Done!' + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' +ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_debian.template b/Dockerfile_debian.template new file mode 100644 index 0000000..43947ec --- /dev/null +++ b/Dockerfile_debian.template @@ -0,0 +1,42 @@ +FROM {{ image.base }} +LABEL {{ image.maintainer }} + +ENV IMAGE {{ os }} +ENV ARCH {{ image.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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ image.s6_version }}/s6-overlay-{{ image.arch }}.tar.gz + +RUN apt-get update && \ + apt-get install -y wget curl net-tools cron && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apt/archives /var/lib/apt/lists/* + +ENTRYPOINT [ "/init" ] + +ADD s6/debian-root / +COPY s6/service /usr/local/bin/service + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' +ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +# not fully supported in debian yet +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 new file mode 100644 index 0000000..df1100f --- /dev/null +++ b/Dockerfile_debian_aarch64 @@ -0,0 +1,42 @@ +FROM multiarch/debian-debootstrap:arm64-jessie-slim +LABEL adam@diginc.us + +ENV IMAGE debian +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-aarch64.tar.gz + +RUN apt-get update && \ + apt-get install -y wget curl net-tools cron && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apt/archives /var/lib/apt/lists/* + +ENTRYPOINT [ "/init" ] + +ADD s6/debian-root / +COPY s6/service /usr/local/bin/service + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' +ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +# not fully supported in debian yet +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 new file mode 100644 index 0000000..9cc26e5 --- /dev/null +++ b/Dockerfile_debian_amd64 @@ -0,0 +1,42 @@ +FROM debian:jessie +LABEL adam@diginc.us + +ENV IMAGE debian +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz + +RUN apt-get update && \ + apt-get install -y wget curl net-tools cron && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apt/archives /var/lib/apt/lists/* + +ENTRYPOINT [ "/init" ] + +ADD s6/debian-root / +COPY s6/service /usr/local/bin/service + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' +ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +# not fully supported in debian yet +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf new file mode 100644 index 0000000..8848f5e --- /dev/null +++ b/Dockerfile_debian_armhf @@ -0,0 +1,42 @@ +FROM multiarch/debian-debootstrap:armhf-jessie-slim +LABEL adam@diginc.us + +ENV IMAGE debian +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz + +RUN apt-get update && \ + apt-get install -y wget curl net-tools cron && \ + curl -L -s $S6OVERLAY_RELEASE \ + | tar xvzf - -C / && \ + docker-install.sh && \ + rm -rf /var/cache/apt/archives /var/lib/apt/lists/* + +ENTRYPOINT [ "/init" ] + +ADD s6/debian-root / +COPY s6/service /usr/local/bin/service + +# php config start passes special ENVs into +ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' +ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' +COPY ./start.sh / +COPY ./bash_functions.sh / + +# IPv6 disable flag for networks/devices that do not support it +# not fully supported in debian yet +ENV IPv6 True + +EXPOSE 53 53/udp +EXPOSE 80 + +ENV S6_LOGGING 0 +ENV S6_KEEP_ENV 1 +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 + +SHELL ["/bin/bash", "-c"] \ No newline at end of file From db443aa0dc030e9a5ae3e07bf5a335c306ce02f4 Mon Sep 17 00:00:00 2001 From: diginc Date: Sun, 1 Oct 2017 23:33:15 -0500 Subject: [PATCH 05/12] alpine template variables swapped in --- Dockerfile_debian.template | 2 +- Dockerfile_debian_aarch64 | 2 +- Dockerfile_debian_amd64 | 2 +- Dockerfile_debian_armhf | 2 +- alpine-arm.docker | 3 ++- alpine-arm64.docker | 3 ++- alpine.docker | 3 ++- debian-armhf.docker | 14 +++++--------- debian.docker | 3 ++- requirements.txt | 1 + 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Dockerfile_debian.template b/Dockerfile_debian.template index 43947ec..1a003bc 100644 --- a/Dockerfile_debian.template +++ b/Dockerfile_debian.template @@ -1,5 +1,5 @@ FROM {{ image.base }} -LABEL {{ image.maintainer }} +LABEL maintainer="{{ image.maintainer }}" ENV IMAGE {{ os }} ENV ARCH {{ image.arch }} diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index df1100f..32b136e 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -1,5 +1,5 @@ FROM multiarch/debian-debootstrap:arm64-jessie-slim -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE debian ENV ARCH aarch64 diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index 9cc26e5..103cc2e 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -1,5 +1,5 @@ FROM debian:jessie -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE debian ENV ARCH amd64 diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index 8848f5e..8e298af 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -1,5 +1,5 @@ FROM multiarch/debian-debootstrap:armhf-jessie-slim -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE debian ENV ARCH armhf diff --git a/alpine-arm.docker b/alpine-arm.docker index 0d05255..f15cf80 100644 --- a/alpine-arm.docker +++ b/alpine-arm.docker @@ -2,12 +2,13 @@ FROM multiarch/alpine:armhf-edge MAINTAINER adam@diginc.us ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.19.1.1/s6-overlay-armhf.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/alpine-arm64.docker b/alpine-arm64.docker index 34db0af..30a93c4 100644 --- a/alpine-arm64.docker +++ b/alpine-arm64.docker @@ -2,12 +2,13 @@ FROM multiarch/alpine:aarch64-edge MAINTAINER adam@diginc.us ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.19.1.1/s6-overlay-aarch64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-aarch64.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/alpine.docker b/alpine.docker index 6ea64d9..7989a10 100644 --- a/alpine.docker +++ b/alpine.docker @@ -2,12 +2,13 @@ FROM alpine:edge MAINTAINER adam@diginc.us ENV IMAGE alpine +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.19.1.1/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/debian-armhf.docker b/debian-armhf.docker index 5ce57ca..a4b6ec5 100644 --- a/debian-armhf.docker +++ b/debian-armhf.docker @@ -1,21 +1,19 @@ -FROM jsurf/rpi-raspbian -MAINTAINER adam@diginc.us +FROM {{ image.base }} +LABEL maintainer="{{ image.maintainer }}" -RUN [ "cross-build-start" ] - -ENV IMAGE debian +ENV IMAGE {{ os }} +ENV ARCH {{ image.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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.19.1.1/s6-overlay-armhf.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz RUN apt-get update && \ apt-get install -y wget curl net-tools cron && \ curl -L -s $S6OVERLAY_RELEASE \ | tar xvzf - -C / && \ - ln /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3 && \ docker-install.sh && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* @@ -42,5 +40,3 @@ ENV S6_KEEP_ENV 1 ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 SHELL ["/bin/bash", "-c"] - -RUN [ "cross-build-end" ] diff --git a/debian.docker b/debian.docker index fe9c060..89b32c2 100644 --- a/debian.docker +++ b/debian.docker @@ -2,12 +2,13 @@ FROM debian:jessie MAINTAINER adam@diginc.us ENV IMAGE debian +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.19.1.1/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz RUN apt-get update && \ apt-get install -y wget curl net-tools cron && \ diff --git a/requirements.txt b/requirements.txt index 00e7363..04a28a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ pytest pytest-cov pytest-xdist testinfra==1.5.1 +jinja2 From 18997fe9f61a9fb2a0836a948e449131b10be501 Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 2 Oct 2017 22:52:02 -0500 Subject: [PATCH 06/12] templated dockerfiles building used by tests * test images are built without diginc/ namespace * no tests for other archs yet, unsure if they'll even build on travis * Removed old dockerfiles * New files names require Docker Cloud reconfiguration when merged upstream * Probably some stuff I missed, just ask me --- DockerfileGeneration.py | 20 +++++----- Dockerfile_alpine.template | 4 +- Dockerfile_alpine_aarch64 | 4 +- Dockerfile_alpine_amd64 | 2 +- Dockerfile_alpine_armhf | 4 +- alpine-arm.docker | 61 ------------------------------- alpine-arm64.docker | 61 ------------------------------- alpine.docker | 61 ------------------------------- debian-armhf.docker | 42 --------------------- debian.docker | 42 --------------------- test/conftest.py | 12 +++--- test/test_000_build_containers.py | 32 ++++++++++------ test/test_bash_functions.py | 12 +++--- 13 files changed, 50 insertions(+), 307 deletions(-) delete mode 100644 alpine-arm.docker delete mode 100644 alpine-arm64.docker delete mode 100644 alpine.docker delete mode 100644 debian-armhf.docker delete mode 100644 debian.docker diff --git a/DockerfileGeneration.py b/DockerfileGeneration.py index aa99ffb..4c7454c 100644 --- a/DockerfileGeneration.py +++ b/DockerfileGeneration.py @@ -4,36 +4,36 @@ import os THIS_DIR = os.path.dirname(os.path.abspath(__file__)) base_vars = { - 'name': 'diginc/pi-hole', + 'name': 'pi-hole', 'maintainer' : 'adam@diginc.us', 's6_version' : 'v1.20.0.0', } images = { 'debian': [ - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'debian:jessie', 'arch': 'amd64' }.items()), - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'multiarch/debian-debootstrap:armhf-jessie-slim', 'arch': 'armhf' }.items()), - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'multiarch/debian-debootstrap:arm64-jessie-slim', 'arch': 'aarch64' }.items()), ], 'alpine': [ - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'alpine:edge', 'arch': 'amd64' }.items()), - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'multiarch/alpine:armhf-edge', 'arch': 'armhf' }.items()), - dict(base_vars.items() + { + dict(base_vars.items() + { 'base': 'multiarch/alpine:aarch64-edge', 'arch': 'aarch64' }.items()) @@ -46,9 +46,9 @@ def generate_dockerfiles(): j2_env = Environment(loader=FileSystemLoader(THIS_DIR), trim_blocks=True) template = j2_env.get_template('Dockerfile_{}.template'.format(os)) - - Dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) - with open(Dockerfile, 'w') as f: + + dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) + with open(dockerfile, 'w') as f: f.write(template.render(os=os, image=image)) if __name__ == '__main__': diff --git a/Dockerfile_alpine.template b/Dockerfile_alpine.template index a9ad43e..b605139 100644 --- a/Dockerfile_alpine.template +++ b/Dockerfile_alpine.template @@ -1,5 +1,5 @@ FROM {{ image.base }} -LABEL {{ image.maintainer }} +LABEL maintainer="{{ image.maintainer }}" ENV IMAGE {{ os }} ENV ARCH {{ image.arch }} @@ -8,7 +8,7 @@ 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.20.0.0/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ image.s6_version }}/s6-overlay-{{ image.arch }}.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/Dockerfile_alpine_aarch64 b/Dockerfile_alpine_aarch64 index 0fb30a2..485c93d 100644 --- a/Dockerfile_alpine_aarch64 +++ b/Dockerfile_alpine_aarch64 @@ -1,5 +1,5 @@ FROM multiarch/alpine:aarch64-edge -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE alpine ENV ARCH aarch64 @@ -8,7 +8,7 @@ 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.20.0.0/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-aarch64.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/Dockerfile_alpine_amd64 b/Dockerfile_alpine_amd64 index 8e6a202..30b8a77 100644 --- a/Dockerfile_alpine_amd64 +++ b/Dockerfile_alpine_amd64 @@ -1,5 +1,5 @@ FROM alpine:edge -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE alpine ENV ARCH amd64 diff --git a/Dockerfile_alpine_armhf b/Dockerfile_alpine_armhf index e466ffb..09753dc 100644 --- a/Dockerfile_alpine_armhf +++ b/Dockerfile_alpine_armhf @@ -1,5 +1,5 @@ FROM multiarch/alpine:armhf-edge -LABEL adam@diginc.us +LABEL maintainer="adam@diginc.us" ENV IMAGE alpine ENV ARCH armhf @@ -8,7 +8,7 @@ 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.20.0.0/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ diff --git a/alpine-arm.docker b/alpine-arm.docker deleted file mode 100644 index f15cf80..0000000 --- a/alpine-arm.docker +++ /dev/null @@ -1,61 +0,0 @@ -FROM multiarch/alpine:armhf-edge -MAINTAINER adam@diginc.us - -ENV IMAGE alpine -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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz - -RUN apk upgrade --update && \ - apk add bind-tools wget curl bash libcap && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apk/* - -ENTRYPOINT [ "/init" ] - -ADD s6/alpine-root / -COPY s6/service /usr/local/bin/service - -# Things installer did and fix alpine+nginx differences -ENV WEBLOGDIR /var/log/nginx -ENV PHP_CONFIG '/etc/php5/php-fpm.conf' -RUN mkdir -p /etc/pihole/ && \ - mkdir -p /var/www/html/pihole && \ - mkdir -p /var/www/html/admin/ && \ - chown nginx:nginx /var/www/html && \ - touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ - chown -R nginx:nginx ${WEBLOGDIR} && \ - sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ - sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ - chmod 775 /var/www/html && \ - touch /var/log/pihole.log && \ - chmod 644 /var/log/pihole.log && \ - chown dnsmasq:root /var/log/pihole.log && \ - sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ - setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ - cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ - echo 'Done!' - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' -ENV PHP_ERROR_LOG '/var/log/nginx/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/alpine-arm64.docker b/alpine-arm64.docker deleted file mode 100644 index 30a93c4..0000000 --- a/alpine-arm64.docker +++ /dev/null @@ -1,61 +0,0 @@ -FROM multiarch/alpine:aarch64-edge -MAINTAINER adam@diginc.us - -ENV IMAGE alpine -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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-aarch64.tar.gz - -RUN apk upgrade --update && \ - apk add bind-tools wget curl bash libcap && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apk/* - -ENTRYPOINT [ "/init" ] - -ADD s6/alpine-root / -COPY s6/service /usr/local/bin/service - -# Things installer did and fix alpine+nginx differences -ENV WEBLOGDIR /var/log/nginx -ENV PHP_CONFIG '/etc/php5/php-fpm.conf' -RUN mkdir -p /etc/pihole/ && \ - mkdir -p /var/www/html/pihole && \ - mkdir -p /var/www/html/admin/ && \ - chown nginx:nginx /var/www/html && \ - touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ - chown -R nginx:nginx ${WEBLOGDIR} && \ - sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ - sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ - chmod 775 /var/www/html && \ - touch /var/log/pihole.log && \ - chmod 644 /var/log/pihole.log && \ - chown dnsmasq:root /var/log/pihole.log && \ - sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ - setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ - cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ - echo 'Done!' - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' -ENV PHP_ERROR_LOG '/var/log/nginx/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/alpine.docker b/alpine.docker deleted file mode 100644 index 7989a10..0000000 --- a/alpine.docker +++ /dev/null @@ -1,61 +0,0 @@ -FROM alpine:edge -MAINTAINER adam@diginc.us - -ENV IMAGE alpine -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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz - -RUN apk upgrade --update && \ - apk add bind-tools wget curl bash libcap && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apk/* - -ENTRYPOINT [ "/init" ] - -ADD s6/alpine-root / -COPY s6/service /usr/local/bin/service - -# Things installer did and fix alpine+nginx differences -ENV WEBLOGDIR /var/log/nginx -ENV PHP_CONFIG '/etc/php5/php-fpm.conf' -RUN mkdir -p /etc/pihole/ && \ - mkdir -p /var/www/html/pihole && \ - mkdir -p /var/www/html/admin/ && \ - chown nginx:nginx /var/www/html && \ - touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ - chown -R nginx:nginx ${WEBLOGDIR} && \ - sed -i 's|^user\s*=.*$|user = nginx|' $PHP_CONFIG && \ - sed -i '/^;pid/ s|^;||' $PHP_CONFIG && \ - chmod 775 /var/www/html && \ - touch /var/log/pihole.log && \ - chmod 644 /var/log/pihole.log && \ - chown dnsmasq:root /var/log/pihole.log && \ - sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ - setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ - cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ - echo 'Done!' - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' -ENV PHP_ERROR_LOG '/var/log/nginx/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/debian-armhf.docker b/debian-armhf.docker deleted file mode 100644 index a4b6ec5..0000000 --- a/debian-armhf.docker +++ /dev/null @@ -1,42 +0,0 @@ -FROM {{ image.base }} -LABEL maintainer="{{ image.maintainer }}" - -ENV IMAGE {{ os }} -ENV ARCH {{ image.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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz - -RUN apt-get update && \ - apt-get install -y wget curl net-tools cron && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apt/archives /var/lib/apt/lists/* - -ENTRYPOINT [ "/init" ] - -ADD s6/debian-root / -COPY s6/service /usr/local/bin/service - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' -ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -# not fully supported in debian yet -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/debian.docker b/debian.docker deleted file mode 100644 index 89b32c2..0000000 --- a/debian.docker +++ /dev/null @@ -1,42 +0,0 @@ -FROM debian:jessie -MAINTAINER adam@diginc.us - -ENV IMAGE debian -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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz - -RUN apt-get update && \ - apt-get install -y wget curl net-tools cron && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apt/archives /var/lib/apt/lists/* - -ENTRYPOINT [ "/init" ] - -ADD s6/debian-root / -COPY s6/service /usr/local/bin/service - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' -ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -# not fully supported in debian yet -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/test/conftest.py b/test/conftest.py index d12507b..225bee5 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,7 +1,7 @@ import pytest import testinfra -WEB_SERVER = { 'alpine': 'nginx', 'debian': 'lighttpd' } +WEB_SERVER = { 'alpine_amd64': 'nginx', 'debian_amd64': 'lighttpd' } check_output = testinfra.get_backend( "local://" @@ -9,7 +9,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 'diginc/pi-hole' in image: + if 'pi-hole' 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 @@ -56,7 +56,7 @@ def DockerPersist(request, persist_args, persist_image, persist_cmd, Dig): def args(request): return '-e ServerIP="127.0.0.1" -e ServerIPv6="::1"' -@pytest.fixture(params=['alpine', 'debian']) +@pytest.fixture(params=['alpine_amd64', 'debian_amd64']) def tag(request): return request.param @@ -66,7 +66,7 @@ def webserver(request, tag): @pytest.fixture() def image(request, tag): - return 'diginc/pi-hole:{}'.format(tag) + return 'pi-hole:{}'.format(tag) @pytest.fixture() def cmd(request): @@ -76,7 +76,7 @@ def cmd(request): def persist_args(request): return '-e ServerIP="127.0.0.1" -e ServerIPv6="::1"' -@pytest.fixture(scope='module', params=['alpine', 'debian']) +@pytest.fixture(scope='module', params=['alpine_amd64', 'debian_amd64']) def persist_tag(request): return request.param @@ -86,7 +86,7 @@ def persist_webserver(request, persist_tag): @pytest.fixture(scope='module') def persist_image(request, persist_tag): - return 'diginc/pi-hole:{}'.format(persist_tag) + return 'pi-hole:{}'.format(persist_tag) @pytest.fixture(scope='module') def persist_cmd(request): diff --git a/test/test_000_build_containers.py b/test/test_000_build_containers.py index 1940e8f..64d4339 100644 --- a/test/test_000_build_containers.py +++ b/test/test_000_build_containers.py @@ -1,20 +1,30 @@ ''' This file starts with 000 to make it run first ''' import pytest import testinfra +import DockerfileGeneration run_local = testinfra.get_backend( "local://" ).get_module("Command").run -@pytest.mark.parametrize("upstream,image,tag", [ - ( 'alpine:edge', 'alpine.docker', 'diginc/pi-hole:alpine' ), - ( 'debian:jessie', 'debian.docker', 'diginc/pi-hole:debian' ), - #( 'jsurf/rpi-raspbian', 'debian-armhf.docker', 'diginc/pi-hole:arm' ), + +def test_generate_dockerfiles(): + DockerfileGeneration.generate_dockerfiles() + + +@pytest.mark.parametrize("os, archs", [ + ( 'debian' , DockerfileGeneration.images['debian'] ), + ( 'alpine' , DockerfileGeneration.images['alpine'] ), ]) -def test_build_pihole_image(upstream, image, tag): - run_local('docker pull {}'.format(upstream)) - build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag)) - if build_cmd.rc != 0: - print build_cmd.stdout - print build_cmd.stderr - assert build_cmd.rc == 0 +def test_build_pihole_image(os, archs): + ''' Build the entire matrix of OS+Architecture ''' + for image in archs: + dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) + image_tag = '{}:{}_{}'.format(image['name'], os, image['arch']) + + run_local('docker pull {}'.format(image['base'])) + build_cmd = run_local('docker build -f {} -t {} .'.format(dockerfile, image_tag)) + if build_cmd.rc != 0: + print build_cmd.stdout + print build_cmd.stderr + assert build_cmd.rc == 0 diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index 552067b..56fab81 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -11,10 +11,10 @@ DEFAULTARGS = '-e ServerIP="127.0.0.1" ' ]) def test_IPv6_not_True_removes_ipv6(Docker, tag, args, expected_ipv6, expected_stdout): ''' When a user overrides IPv6=True they only get IPv4 listening webservers ''' - IPV6_LINE = { 'alpine': 'listen [::]:80 default_server', - 'debian': 'use-ipv6.pl' } - WEB_CONFIG = { 'alpine': '/etc/nginx/nginx.conf', - 'debian': '/etc/lighttpd/lighttpd.conf' } + IPV6_LINE = { 'alpine_amd64': 'listen [::]:80 default_server', + 'debian_amd64': 'use-ipv6.pl' } + WEB_CONFIG = { 'alpine_amd64': '/etc/nginx/nginx.conf', + 'debian_amd64': '/etc/lighttpd/lighttpd.conf' } function = Docker.run('. /bash_functions.sh ; setup_ipv4_ipv6') assert "Using {}".format(expected_stdout) in function.stdout @@ -55,8 +55,8 @@ expected_debian_lines = [ '"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"' ] @pytest.mark.parametrize('tag,expected_lines,repeat_function', [ - ('debian', expected_debian_lines, 1), - ('debian', expected_debian_lines, 2) + ('debian_amd64', expected_debian_lines, 1), + ('debian_amd64', expected_debian_lines, 2) ]) def test_debian_setup_php_env(Docker, tag, expected_lines, repeat_function): ''' confirm all expected output is there and nothing else ''' From 51bebbe4af78226dbcf6a987c32b51f2c32113b1 Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 2 Oct 2017 23:14:03 -0500 Subject: [PATCH 07/12] try setting up qemu for travis build machine to fix red --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 40e90eb..4732fba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,8 @@ python: install: - pip install -r requirements.txt -script: py.test -vv test/ +script: + # prepare qemu + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + # run docker build & tests + - py.test -vv test/ From 3c6db584d70edc40a0b7f2579cdc40754b264029 Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 2 Oct 2017 23:46:42 -0500 Subject: [PATCH 08/12] split out test builds for each arch to help avoid travis timeout --- test/test_000_build_containers.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/test_000_build_containers.py b/test/test_000_build_containers.py index 64d4339..64611d6 100644 --- a/test/test_000_build_containers.py +++ b/test/test_000_build_containers.py @@ -11,20 +11,14 @@ run_local = testinfra.get_backend( def test_generate_dockerfiles(): DockerfileGeneration.generate_dockerfiles() - -@pytest.mark.parametrize("os, archs", [ - ( 'debian' , DockerfileGeneration.images['debian'] ), - ( 'alpine' , DockerfileGeneration.images['alpine'] ), -]) -def test_build_pihole_image(os, archs): +@pytest.mark.parametrize('arch', [ 'amd64', 'armhf', 'aarch64' ]) +@pytest.mark.parametrize('os', [ 'debian', 'alpine' ]) +def test_build_pihole_image(os, arch): ''' Build the entire matrix of OS+Architecture ''' - for image in archs: - dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) - image_tag = '{}:{}_{}'.format(image['name'], os, image['arch']) - - run_local('docker pull {}'.format(image['base'])) - build_cmd = run_local('docker build -f {} -t {} .'.format(dockerfile, image_tag)) - if build_cmd.rc != 0: - print build_cmd.stdout - print build_cmd.stderr - assert build_cmd.rc == 0 + dockerfile = 'Dockerfile_{}_{}'.format(os, arch) + image_tag = '{}:{}_{}'.format('pi-hole', os, arch) + build_cmd = run_local('docker build --pull -f {} -t {} .'.format(dockerfile, image_tag)) + if build_cmd.rc != 0: + print build_cmd.stdout + print build_cmd.stderr + assert build_cmd.rc == 0 From f22ee44226e196f1f671e70d5909c4f02c0595d4 Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 4 Oct 2017 11:05:27 -0500 Subject: [PATCH 09/12] Switch to a single template instead of two, jinja logic --- ...ile_alpine.template => Dockerfile.template | 33 +++++++++---- DockerfileGeneration.py | 48 +++++++++++++------ Dockerfile_alpine_aarch64 | 7 ++- Dockerfile_alpine_amd64 | 7 ++- Dockerfile_alpine_armhf | 7 ++- Dockerfile_debian.template | 42 ---------------- Dockerfile_debian_aarch64 | 8 +++- Dockerfile_debian_amd64 | 8 +++- Dockerfile_debian_armhf | 8 +++- bash_functions.sh | 14 +++--- install.sh | 8 ++-- start.sh | 4 +- 12 files changed, 104 insertions(+), 90 deletions(-) rename Dockerfile_alpine.template => Dockerfile.template (66%) delete mode 100644 Dockerfile_debian.template diff --git a/Dockerfile_alpine.template b/Dockerfile.template similarity index 66% rename from Dockerfile_alpine.template rename to Dockerfile.template index b605139..6d387c5 100644 --- a/Dockerfile_alpine.template +++ b/Dockerfile.template @@ -1,27 +1,40 @@ -FROM {{ image.base }} -LABEL maintainer="{{ image.maintainer }}" +FROM {{ pihole.base }} -ENV IMAGE {{ os }} -ENV ARCH {{ image.arch }} +LABEL image="{{ pihole.name }}:{{ pihole.os }}_{{ pihole.arch }}" +LABEL maintainer="{{ pihole.maintainer }}" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG {{ pihole.os }} +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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ image.s6_version }}/s6-overlay-{{ image.arch }}.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ pihole.s6_version }}/s6-overlay-{{ pihole.arch }}.tar.gz +{% if pihole.os == 'alpine' %} RUN apk upgrade --update && \ apk add bind-tools wget curl bash libcap && \ +{% else %} +RUN apt-get update && \ + apt-get install -y wget curl net-tools cron && \ +{% endif %} curl -L -s $S6OVERLAY_RELEASE \ | tar xvzf - -C / && \ docker-install.sh && \ +{% if pihole.os == 'alpine' %} rm -rf /var/cache/apk/* +{% else %} + rm -rf /var/cache/apt/archives /var/lib/apt/lists/* +{% endif %} ENTRYPOINT [ "/init" ] -ADD s6/alpine-root / +ADD s6/{{ pihole.os }}-root / COPY s6/service /usr/local/bin/service +{% if pihole.os == 'alpine' %} # Things installer did and fix alpine+nginx differences ENV WEBLOGDIR /var/log/nginx ENV PHP_CONFIG '/etc/php5/php-fpm.conf' @@ -41,14 +54,18 @@ RUN mkdir -p /etc/pihole/ && \ setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \ cp -f /usr/bin/list.sh /opt/pihole/list.sh && \ echo 'Done!' +{% endif %} # php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf' -ENV PHP_ERROR_LOG '/var/log/nginx/error.log' +ENV PHP_ENV_CONFIG '{{ pihole.php_env_config }}' +ENV PHP_ERROR_LOG '{{ pihole.php_error_log }}' COPY ./start.sh / COPY ./bash_functions.sh / # IPv6 disable flag for networks/devices that do not support it +{% if pihole.os == 'debian' %} +# not fully supported in debian yet +{% endif %} ENV IPv6 True EXPOSE 53 53/udp diff --git a/DockerfileGeneration.py b/DockerfileGeneration.py index 4c7454c..40070de 100644 --- a/DockerfileGeneration.py +++ b/DockerfileGeneration.py @@ -4,52 +4,70 @@ import os THIS_DIR = os.path.dirname(os.path.abspath(__file__)) base_vars = { - 'name': 'pi-hole', + 'name': 'diginc/pi-hole', 'maintainer' : 'adam@diginc.us', 's6_version' : 'v1.20.0.0', } +os_base_vars = { + 'debian': { + 'php_env_config': '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf', + 'php_error_log': '/var/log/lighttpd/error.log' + }, + 'alpine': { + 'php_env_config': '/etc/php5/fpm.d/envs.conf', + 'php_error_log': '/var/log/nginx/error.log' + } +} + images = { 'debian': [ - dict(base_vars.items() + { + { 'base': 'debian:jessie', 'arch': 'amd64' - }.items()), - dict(base_vars.items() + { + }, + { 'base': 'multiarch/debian-debootstrap:armhf-jessie-slim', 'arch': 'armhf' - }.items()), - dict(base_vars.items() + { + }, + { 'base': 'multiarch/debian-debootstrap:arm64-jessie-slim', 'arch': 'aarch64' - }.items()), + } ], 'alpine': [ - dict(base_vars.items() + { + { 'base': 'alpine:edge', 'arch': 'amd64' - }.items()), - dict(base_vars.items() + { + }, + { 'base': 'multiarch/alpine:armhf-edge', 'arch': 'armhf' - }.items()), - dict(base_vars.items() + { + }, + { 'base': 'multiarch/alpine:aarch64-edge', 'arch': 'aarch64' - }.items()) + } ] } def generate_dockerfiles(): for os, archs in images.iteritems(): for image in archs: + merged_data = dict( + { 'os': os }.items() + + base_vars.items() + + os_base_vars[os].items() + + image.items() + ) j2_env = Environment(loader=FileSystemLoader(THIS_DIR), trim_blocks=True) - template = j2_env.get_template('Dockerfile_{}.template'.format(os)) + template = j2_env.get_template('Dockerfile.template') dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch']) with open(dockerfile, 'w') as f: - f.write(template.render(os=os, image=image)) + f.write(template.render(pihole=merged_data)) + if __name__ == '__main__': generate_dockerfiles() diff --git a/Dockerfile_alpine_aarch64 b/Dockerfile_alpine_aarch64 index 485c93d..fec9dbb 100644 --- a/Dockerfile_alpine_aarch64 +++ b/Dockerfile_alpine_aarch64 @@ -1,7 +1,10 @@ FROM multiarch/alpine:aarch64-edge -LABEL maintainer="adam@diginc.us" -ENV IMAGE alpine +LABEL image="diginc/pi-hole:alpine_aarch64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG alpine ENV ARCH aarch64 ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_alpine_amd64 b/Dockerfile_alpine_amd64 index 30b8a77..4608962 100644 --- a/Dockerfile_alpine_amd64 +++ b/Dockerfile_alpine_amd64 @@ -1,7 +1,10 @@ FROM alpine:edge -LABEL maintainer="adam@diginc.us" -ENV IMAGE alpine +LABEL image="diginc/pi-hole:alpine_amd64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG alpine ENV ARCH amd64 ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_alpine_armhf b/Dockerfile_alpine_armhf index 09753dc..340d65e 100644 --- a/Dockerfile_alpine_armhf +++ b/Dockerfile_alpine_armhf @@ -1,7 +1,10 @@ FROM multiarch/alpine:armhf-edge -LABEL maintainer="adam@diginc.us" -ENV IMAGE alpine +LABEL image="diginc/pi-hole:alpine_armhf" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG alpine ENV ARCH armhf ENV PATH /opt/pihole:${PATH} diff --git a/Dockerfile_debian.template b/Dockerfile_debian.template deleted file mode 100644 index 1a003bc..0000000 --- a/Dockerfile_debian.template +++ /dev/null @@ -1,42 +0,0 @@ -FROM {{ image.base }} -LABEL maintainer="{{ image.maintainer }}" - -ENV IMAGE {{ os }} -ENV ARCH {{ image.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 S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/{{ image.s6_version }}/s6-overlay-{{ image.arch }}.tar.gz - -RUN apt-get update && \ - apt-get install -y wget curl net-tools cron && \ - curl -L -s $S6OVERLAY_RELEASE \ - | tar xvzf - -C / && \ - docker-install.sh && \ - rm -rf /var/cache/apt/archives /var/lib/apt/lists/* - -ENTRYPOINT [ "/init" ] - -ADD s6/debian-root / -COPY s6/service /usr/local/bin/service - -# php config start passes special ENVs into -ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' -ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' -COPY ./start.sh / -COPY ./bash_functions.sh / - -# IPv6 disable flag for networks/devices that do not support it -# not fully supported in debian yet -ENV IPv6 True - -EXPOSE 53 53/udp -EXPOSE 80 - -ENV S6_LOGGING 0 -ENV S6_KEEP_ENV 1 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2 - -SHELL ["/bin/bash", "-c"] diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index 32b136e..33caa7d 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -1,7 +1,10 @@ FROM multiarch/debian-debootstrap:arm64-jessie-slim -LABEL maintainer="adam@diginc.us" -ENV IMAGE debian +LABEL image="diginc/pi-hole:debian_aarch64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG debian ENV ARCH aarch64 ENV PATH /opt/pihole:${PATH} @@ -22,6 +25,7 @@ ENTRYPOINT [ "/init" ] ADD s6/debian-root / COPY s6/service /usr/local/bin/service + # php config start passes special ENVs into ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index 103cc2e..3600d64 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -1,7 +1,10 @@ FROM debian:jessie -LABEL maintainer="adam@diginc.us" -ENV IMAGE debian +LABEL image="diginc/pi-hole:debian_amd64" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG debian ENV ARCH amd64 ENV PATH /opt/pihole:${PATH} @@ -22,6 +25,7 @@ ENTRYPOINT [ "/init" ] ADD s6/debian-root / COPY s6/service /usr/local/bin/service + # php config start passes special ENVs into ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index 8e298af..e19eecb 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -1,7 +1,10 @@ FROM multiarch/debian-debootstrap:armhf-jessie-slim -LABEL maintainer="adam@diginc.us" -ENV IMAGE debian +LABEL image="diginc/pi-hole:debian_armhf" +LABEL maintainer="adam@diginc.us" +LABEL url="https://www.github.com/diginc/docker-pi-hole" + +ENV TAG debian ENV ARCH armhf ENV PATH /opt/pihole:${PATH} @@ -22,6 +25,7 @@ ENTRYPOINT [ "/init" ] ADD s6/debian-root / COPY s6/service /usr/local/bin/service + # php config start passes special ENVs into ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' diff --git a/bash_functions.sh b/bash_functions.sh index 674dac9..f02b1bf 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -17,7 +17,7 @@ validate_env() { # Debian nc_error='Name or service not known' - if [[ "$IMAGE" == 'alpine' ]] ; then + if [[ "$TAG" == 'alpine' ]] ; then nc_error='bad address' fi; @@ -119,7 +119,7 @@ setup_dnsmasq_hostnames() { } setup_lighttpd_bind() { - if [[ "$IMAGE" == 'debian' ]] ; then + if [[ "$TAG" == 'debian' ]] ; then # if using '--net=host' only bind lighttpd on $ServerIP 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 @@ -130,7 +130,7 @@ setup_lighttpd_bind() { } setup_php_env() { - case $IMAGE in + case $TAG in "debian") setup_php_env_debian ;; "alpine") setup_php_env_alpine ;; esac @@ -192,7 +192,7 @@ setup_ipv4_ipv6() { local ip_versions="IPv4 and IPv6" if [ "$IPv6" != "True" ] ; then ip_versions="IPv4" - case $IMAGE in + case $TAG in "debian") sed -i '/use-ipv6.pl/ d' /etc/lighttpd/lighttpd.conf ;; "alpine") sed -i '/listen \[::\]:80/ d' /etc/nginx/nginx.conf ;; esac @@ -201,7 +201,7 @@ setup_ipv4_ipv6() { } test_configs() { - case $IMAGE in + case $TAG in "debian") test_configs_debian ;; "alpine") test_configs_alpine ;; esac @@ -241,8 +241,8 @@ docker_main() { echo -n '::: Starting up DNS and Webserver ...' service dnsmasq restart # Just get DNS up. The webserver is down!!! - IMAGE="$1" - case $IMAGE in # Setup webserver + TAG="$1" + case $TAG in # Setup webserver "alpine") php-fpm5 nginx diff --git a/install.sh b/install.sh index 8b838ba..a1af9e2 100755 --- a/install.sh +++ b/install.sh @@ -13,7 +13,7 @@ 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 -if [[ "$IMAGE" == 'alpine' ]] ; then +if [[ "$TAG" == 'alpine' ]] ; then sed -i '/OS distribution not supported/ i\ echo "Hi Alpine"' "$PIHOLE_INSTALL" sed -i '/OS distribution not supported/,+1d' "$PIHOLE_INSTALL" sed -i 's#nologin pihole#nologin pihole 2>/dev/null || adduser -S -s /sbin/nologin pihole#g' "$PIHOLE_INSTALL" @@ -36,7 +36,7 @@ PH_TEST=true . "${PIHOLE_INSTALL}" # Run only what we need from installer export USER=pihole -if [[ "$IMAGE" == 'debian' ]] ; then +if [[ "$TAG" == 'debian' ]] ; then distro_check install_dependent_packages INSTALLER_DEPS[@] install_dependent_packages PIHOLE_DEPS[@] @@ -44,7 +44,7 @@ if [[ "$IMAGE" == 'debian' ]] ; then 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 -elif [[ "$IMAGE" == 'alpine' ]] ; then +elif [[ "$TAG" == 'alpine' ]] ; then apk add \ dnsmasq \ nginx \ @@ -74,7 +74,7 @@ tmpLog="${tmpLog}" instalLogLoc="${instalLogLoc}" installPihole | tee "${tmpLog}" sed -i 's/readonly //g' /opt/pihole/webpage.sh -if [[ "$IMAGE" == 'alpine' ]] ; then +if [[ "$TAG" == 'alpine' ]] ; then cp /etc/.pihole/advanced/pihole.cron /etc/crontabs/pihole # Fix hostname bug on block page diff --git a/start.sh b/start.sh index 2e4585a..55e3441 100755 --- a/start.sh +++ b/start.sh @@ -1,6 +1,6 @@ #!/bin/bash -e # Dockerfile variables -export IMAGE +export TAG export ServerIP export ServerIPv6 export PYTEST @@ -25,7 +25,7 @@ setup_dnsmasq "$DNS1" "$DNS2" setup_php_env setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME" setup_ipv4_ipv6 -setup_lighttpd_bind "$ServerIP" "$IMAGE" +setup_lighttpd_bind "$ServerIP" "$TAG" test_configs test_framework_stubbing echo "::: Docker start setup complete - beginning s6 services" From d98837c8288de8b5c8a86a97f1812973d8f42182 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 5 Oct 2017 11:59:19 -0500 Subject: [PATCH 10/12] expand most tests to run for all os arch combos --- test/conftest.py | 12 ++++++++++-- test/test_bash_functions.py | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 225bee5..b2f336b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -56,10 +56,18 @@ def DockerPersist(request, persist_args, persist_image, persist_cmd, Dig): def args(request): return '-e ServerIP="127.0.0.1" -e ServerIPv6="::1"' -@pytest.fixture(params=['alpine_amd64', 'debian_amd64']) -def tag(request): +@pytest.fixture(params=['amd64', 'armhf', 'aarch64']) +def arch(request): return request.param +@pytest.fixture(params=['debian', 'alpine']) +def os(request): + return request.param + +@pytest.fixture() +def tag(request, os, arch): + return '{}_{}'.format(os, arch) + @pytest.fixture def webserver(request, tag): return WEB_SERVER[tag] diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index 56fab81..344beb1 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -9,17 +9,17 @@ 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, tag, args, expected_ipv6, expected_stdout): +def test_IPv6_not_True_removes_ipv6(Docker, os, args, expected_ipv6, expected_stdout): ''' When a user overrides IPv6=True they only get IPv4 listening webservers ''' - IPV6_LINE = { 'alpine_amd64': 'listen [::]:80 default_server', - 'debian_amd64': 'use-ipv6.pl' } - WEB_CONFIG = { 'alpine_amd64': '/etc/nginx/nginx.conf', - 'debian_amd64': '/etc/lighttpd/lighttpd.conf' } + IPV6_LINE = { 'alpine': 'listen [::]:80 default_server', + 'debian': 'use-ipv6.pl' } + WEB_CONFIG = { 'alpine': '/etc/nginx/nginx.conf', + 'debian': '/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[tag])).stdout - assert (IPV6_LINE[tag] in config) == expected_ipv6 + config = Docker.run('cat {}'.format( WEB_CONFIG[os])).stdout + assert (IPV6_LINE[os] in config) == expected_ipv6 @pytest.mark.parametrize('args, expected_stdout, dns1, dns2', [ ('-e ServerIP="1.2.3.4"', 'default DNS', '8.8.8.8', '8.8.4.4' ), @@ -54,11 +54,11 @@ expected_debian_lines = [ '"ServerIP" => "127.0.0.1"', '"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"' ] -@pytest.mark.parametrize('tag,expected_lines,repeat_function', [ - ('debian_amd64', expected_debian_lines, 1), - ('debian_amd64', expected_debian_lines, 2) +@pytest.mark.parametrize('os,expected_lines,repeat_function', [ + ('debian', expected_debian_lines, 1), + ('debian', expected_debian_lines, 2) ]) -def test_debian_setup_php_env(Docker, tag, expected_lines, repeat_function): +def test_debian_setup_php_env(Docker, os, expected_lines, repeat_function): ''' confirm all expected output is there and nothing else ''' stdout = '' for i in range(repeat_function): From bbdf2887e1bb7b0af35d679015c6903735e772c2 Mon Sep 17 00:00:00 2001 From: mr-bolle Date: Mon, 9 Oct 2017 17:13:31 +0200 Subject: [PATCH 11/12] update pi-hole to FTL to 2.11.1 https://github.com/pi-hole/FTL/releases/tag/v2.11.1 --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e3211ab..97a19e4 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ mkdir -p /etc/pihole/ export CORE_TAG='v3.1.4' export WEB_TAG='v3.1' -export FTL_TAG='v2.10' +export FTL_TAG='v2.11.1' # Make pihole scripts fail searching for `systemctl`, # which fails pretty miserably in docker compared to `service` From 499ebe2f8a9fe477bad4119ade91f0ce449fe7b3 Mon Sep 17 00:00:00 2001 From: vidschofelix Date: Sat, 14 Oct 2017 14:53:29 +0200 Subject: [PATCH 12/12] fix missing newline --- bash_functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bash_functions.sh b/bash_functions.sh index 674dac9..4b04c5d 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -188,6 +188,7 @@ setup_web_password() { fi { set +x; } 2>/dev/null } + setup_ipv4_ipv6() { local ip_versions="IPv4 and IPv6" if [ "$IPv6" != "True" ] ; then