Merge branch 'master' of github.com:diginc/docker-pi-hole into dev

This commit is contained in:
diginc 2016-08-28 02:05:50 -05:00
commit bf50686b9f
12 changed files with 27 additions and 137 deletions

2
.gitmodules vendored
View File

@ -3,4 +3,4 @@
url = https://github.com/pi-hole/pi-hole.git
[submodule "AdminLTE"]
path = AdminLTE
url = https://github.com/pi-hole/AdminLTE.git
url = https://github.com/diginc/AdminLTE.git

View File

@ -1,10 +1,12 @@
sudo: required
services:
- docker
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
script: py.test -v
before_install:
- docker pull diginc/pi-hole:alpine
- docker pull diginc/pi-hole:debian
script:
- docker build -f alpine.docker .
- docker build -f debian.docker .

View File

@ -1,6 +1,10 @@
A [Docker](https://www.docker.com/what-docker) project to make lightweight x86 continers with [pi-hole](https://pi-hole.net) functionality. Why? Maybe you don't have a Raspberry Pi lying around but you do have a Docker server.
[![Build Status](https://travis-ci.org/diginc/docker-pi-hole.svg?branch=master)](https://travis-ci.org/diginc/docker-pi-hole)
[![Docker Stars](https://img.shields.io/docker/stars/diginc/pi-hole.svg?maxAge=2592000)](https://hub.docker.com/r/diginc/pi-hole/)
[![Docker Pulls](https://img.shields.io/docker/pulls/diginc/pi-hole.svg?maxAge=2592000)](https://hub.docker.com/r/diginc/pi-hole/)
[![Join the chat at https://gitter.im/diginc/docker-pi-hole](https://badges.gitter.im/diginc/docker-pi-hole.svg)](https://gitter.im/diginc/docker-pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**April 25, 2016 Update**: the 'piholeIP' env var has been replaced by 'ServerIP' env var, update your docker run/docker-compose configs accordingly please.
@ -43,12 +47,18 @@ All of these options get really long when strung together in one command, which
### Alpine
[![](https://badge.imagelayers.io/diginc/pi-hole:alpine.svg)](https://imagelayers.io/?images=diginc/pi-hole:alpine 'Get your own badge on imagelayers.io')
[![](https://images.microbadger.com/badges/image/diginc/pi-hole.svg)](http://microbadger.com/images/diginc/pi-hole "Get your own image badge on microbadger.com")
[![](https://images.microbadger.com/badges/version/diginc/pi-hole.svg)](http://microbadger.com/images/diginc/pi-hole "Get your own version badge on microbadger.com")
[![Dockerfile](https://github.com/diginc/docker-pi-hole/blob/master/alpine.docker)]
This is an optimized docker using [alpine](https://hub.docker.com/_/alpine/) as its base. It uses nginx instead of lighttpd.
### Debian
[![](https://badge.imagelayers.io/diginc/pi-hole:debian.svg)](https://imagelayers.io/?images=diginc/pi-hole:debian 'Get your own badge on imagelayers.io')
[![](https://images.microbadger.com/badges/image/diginc/pi-hole:debian.svg)](http://microbadger.com/images/diginc/pi-hole "Get your own image badge on microbadger.com")
[![](https://images.microbadger.com/badges/version/diginc/pi-hole:debian.svg)](http://microbadger.com/images/diginc/pi-hole "Get your own version badge on microbadger.com")
[![Dockerfile](https://github.com/diginc/docker-pi-hole/blob/master/debian.docker)]
This version of the docker aims to be as close to a standard pi-hole installation by using the same base OS and the exact configs and scripts (minimally modified to get them working). This serves as a nice baseline for merging and testing upstream repository pi-hole changes.

View File

@ -20,7 +20,7 @@ COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/
RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
COPY ./pi-hole/advanced/index* /var/www/html/pihole/
COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html
COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole
COPY ./AdminLTE /var/www/html/admin
COPY ./AdminLTE_version.txt /etc/

View File

@ -13,7 +13,7 @@ echo "env[ServerIP] = ${ServerIP}" >> $PHP_ENV_CONFIG;
if [ -n "$VIRTUAL_HOST" ] ; then
echo "env[VIRTUAL_HOST] = ${VIRTUAL_HOST}" >> $PHP_ENV_CONFIG;
else
else
echo "env[VIRTUAL_HOST] = ${ServerIP}" >> $PHP_ENV_CONFIG;
fi;
@ -23,7 +23,7 @@ cat $PHP_ENV_CONFIG
dnsType='default'
DNS1=${DNS1:-'8.8.8.8'}
DNS2=${DNS2:-'8.8.4.4'}
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
dnsType='custom'
fi;
@ -34,9 +34,7 @@ sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \
dnsmasq --test -7 /etc/dnsmasq.d || exit 1
php-fpm -t || exit 1
nginx -t || exit 1
echo " :: All config checks passed, starting ..."
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup/#donotcurl/g' `which gravity.sh`; fi;
gravity.sh
dnsmasq -7 /etc/dnsmasq.d
php-fpm

View File

@ -1 +0,0 @@
py.test -v -f test/

View File

@ -1,60 +0,0 @@
FROM resin/armv7hf-debian:jessie
MAINTAINER adam@diginc.us <adam@diginc.us>
# Requirements
RUN apt-get -q update && \
apt-get install -y \
bash \
dnsmasq \
lighttpd \
php5-common php5-cgi php5 \
bc curl unzip wget sudo && \
rm -rf /var/cache/apt/archives
# Original upstream pihole code being used
COPY ./pi-hole/gravity.sh /usr/local/bin/
COPY ./pi-hole/adlists.default /etc/pihole/
COPY ./pi-hole/pihole /usr/local/bin/
COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/
RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole
COPY ./pi-hole/advanced/lighttpd.conf.debian /etc/lighttpd/lighttpd.conf
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html
COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole
COPY ./AdminLTE /var/www/html/admin
COPY ./AdminLTE_version.txt /etc/
COPY ./pi-hole_version.txt /etc/
ENV WEBLOGDIR /var/log/lighttpd
RUN mkdir -p /etc/pihole/ && \
mkdir -p /var/www/html/pihole && \
mkdir -p /var/www/html/admin/ && \
chown www-data:www-data /var/www/html && \
touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \
chown -R www-data.www-data ${WEBLOGDIR} && \
chmod 775 /var/www/html && \
lighty-enable-mod fastcgi fastcgi-php || true && \
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 && \
sed -i 's|"cd /etc/.pihole/ && git describe --tags --abbrev=0"|"cat /etc/pi-hole_version.txt"|g' /var/www/html/admin/footer.php && \
sed -i 's|"git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php
# This chould be eliminated if all (upstream) files were +x in git
RUN chmod +x /usr/local/bin/*.sh
# Fix dnsmasq in docker
RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf
# 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 ./debian-armhf/start.sh /
EXPOSE 53 53/udp
EXPOSE 80
ENTRYPOINT ["/bash", "-c"]
CMD /start.sh

View File

@ -1,38 +0,0 @@
#!/bin/sh
if [ -z "$ServerIP" ] ; then
echo "ERROR: To function correctly you must pass an environment variables of 'ServerIP' into the docker container with the IP of your docker host from which you are passing web (80) and dns (53) ports from"
exit 1
fi;
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
echo "$ServerIP" > /etc/pihole/piholeIP;
sed -i "/bin-environment/ a\\\t\t\t\"ServerIP\" => \"${ServerIP}\"," $PHP_ENV_CONFIG
sed -i "/bin-environment/ a\\\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\"," $PHP_ENV_CONFIG
if [ -n "$VIRTUAL_HOST" ] ; then
sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${VIRTUAL_HOST}\"," $PHP_ENV_CONFIG
else
sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${ServerIP}\"," $PHP_ENV_CONFIG
fi;
echo "Added ENV to php:"
grep -E '(VIRTUAL_HOST|ServerIP)' $PHP_ENV_CONFIG
dnsType='default'
DNS1=${DNS1:-'8.8.8.8'}
DNS2=${DNS2:-'8.8.4.4'}
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
dnsType='custom'
fi;
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
sed -i "s/@DNS1@/$DNS1/" /etc/dnsmasq.d/01-pihole.conf && \
sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \
dnsmasq --test -7 /etc/dnsmasq.d || exit 1
lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1
gravity.sh # dnsmasq start included
service lighttpd start
tail -F /var/log/lighttpd/*.log /var/log/pihole.log

View File

@ -26,8 +26,7 @@ RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole
COPY ./pi-hole/advanced/lighttpd.conf.debian /etc/lighttpd/lighttpd.conf
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
COPY ./pi-hole/advanced/index* /var/www/html/pihole/
RUN rm /var/www/html/index.lighttpd.html
COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html
COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole
COPY ./AdminLTE /var/www/html/admin
COPY ./AdminLTE_version.txt /etc/

6
debian/start.sh vendored
View File

@ -11,7 +11,7 @@ sed -i "/bin-environment/ a\\\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\"," $
if [ -n "$VIRTUAL_HOST" ] ; then
sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${VIRTUAL_HOST}\"," $PHP_ENV_CONFIG
else
else
sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${ServerIP}\"," $PHP_ENV_CONFIG
fi;
@ -21,7 +21,7 @@ grep -E '(VIRTUAL_HOST|ServerIP)' $PHP_ENV_CONFIG
dnsType='default'
DNS1=${DNS1:-'8.8.8.8'}
DNS2=${DNS2:-'8.8.4.4'}
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
dnsType='custom'
fi;
@ -31,9 +31,7 @@ sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \
dnsmasq --test -7 /etc/dnsmasq.d || exit 1
lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1
echo " :: All config checks passed, starting ..."
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup/#donotcurl/g' `which gravity.sh`; fi;
gravity.sh # dnsmasq start included
service lighttpd start

View File

View File

@ -1,18 +0,0 @@
''' This file starts with 000 to make it run first '''
import pytest
import testinfra
run_local = testinfra.get_backend(
"local://"
).get_module("Command").run
@pytest.mark.parametrize("image,tag", [
( 'alpine.docker', 'diginc/pi-hole:alpine' ),
( 'debian.docker', 'diginc/pi-hole:debian' ),
])
def test_build_pihole_image(image, tag):
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