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