Skip to content

Commit

Permalink
Merge pull request #173 from diginc/dev
Browse files Browse the repository at this point in the history
Release latest version to master & mainline tags
  • Loading branch information
diginc authored Oct 16, 2017
2 parents 11a49ca + e6b175e commit 885ef2d
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
78 changes: 78 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM {{ pihole.base }}

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/{{ 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/{{ 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'
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!'
{% endif %}

# php config start passes special ENVs into
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
EXPOSE 80

ENV S6_LOGGING 0
ENV S6_KEEP_ENV 1
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2

SHELL ["/bin/bash", "-c"]
73 changes: 73 additions & 0 deletions DockerfileGeneration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from jinja2 import Environment, FileSystemLoader
import os

THIS_DIR = os.path.dirname(os.path.abspath(__file__))

base_vars = {
'name': 'diginc/pi-hole',
'maintainer' : '[email protected]',
'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': [
{
'base': 'debian:jessie',
'arch': 'amd64'
},
{
'base': 'multiarch/debian-debootstrap:armhf-jessie-slim',
'arch': 'armhf'
},
{
'base': 'multiarch/debian-debootstrap:arm64-jessie-slim',
'arch': 'aarch64'
}
],
'alpine': [
{
'base': 'alpine:edge',
'arch': 'amd64'
},
{
'base': 'multiarch/alpine:armhf-edge',
'arch': 'armhf'
},
{
'base': 'multiarch/alpine:aarch64-edge',
'arch': 'aarch64'
}
]
}

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')

dockerfile = 'Dockerfile_{}_{}'.format(os, image['arch'])
with open(dockerfile, 'w') as f:
f.write(template.render(pihole=merged_data))


if __name__ == '__main__':
generate_dockerfiles()
64 changes: 64 additions & 0 deletions Dockerfile_alpine_aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM multiarch/alpine:aarch64-edge

LABEL image="diginc/pi-hole:alpine_aarch64"
LABEL maintainer="[email protected]"
LABEL url="https://www.github.com/diginc/docker-pi-hole"

ENV TAG 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"]
12 changes: 8 additions & 4 deletions alpine.docker → Dockerfile_alpine_amd64
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM alpine:edge
MAINTAINER [email protected] <[email protected]>

ENV IMAGE alpine
LABEL image="diginc/pi-hole:alpine_amd64"
LABEL maintainer="[email protected]"
LABEL url="https://www.github.com/diginc/docker-pi-hole"

ENV TAG 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 && \
Expand Down Expand Up @@ -57,4 +61,4 @@ ENV S6_LOGGING 0
ENV S6_KEEP_ENV 1
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2

SHELL ["/bin/bash", "-c"]
SHELL ["/bin/bash", "-c"]
64 changes: 64 additions & 0 deletions Dockerfile_alpine_armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM multiarch/alpine:armhf-edge

LABEL image="diginc/pi-hole:alpine_armhf"
LABEL maintainer="[email protected]"
LABEL url="https://www.github.com/diginc/docker-pi-hole"

ENV TAG 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"]
46 changes: 46 additions & 0 deletions Dockerfile_debian_aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM multiarch/debian-debootstrap:arm64-jessie-slim

LABEL image="diginc/pi-hole:debian_aarch64"
LABEL maintainer="[email protected]"
LABEL url="https://www.github.com/diginc/docker-pi-hole"

ENV TAG 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"]
Loading

0 comments on commit 885ef2d

Please sign in to comment.