debian converted to s6, aline files moved

This commit is contained in:
diginc 2017-05-05 21:48:03 -05:00
parent 20955a41fe
commit 9f61b87198
25 changed files with 69 additions and 47 deletions

View File

@ -18,11 +18,8 @@ RUN apk upgrade --update && \
ENTRYPOINT [ "/init" ]
ADD alpine/root /
COPY ./alpine/service /usr/local/bin/service
# Customized from submodules
COPY ./alpine/nginx.conf /etc/nginx/nginx.conf
ADD s6/alpine-root /
COPY s6/service /usr/local/bin/service
# Things installer did and fix alpine+nginx differences
ENV WEBLOGDIR /var/log/nginx
@ -52,7 +49,7 @@ 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
# IPv6 disable flag for networks/devices that do not support it
ENV IPv6 True
EXPOSE 53 53/udp
@ -60,7 +57,5 @@ EXPOSE 80
ENV S6_LOGGING 0
ENV S6_KEEP_ENV 1
#ENV S6_LOGGING_SCRIPT "n20 s1000000 T"
SHELL ["/bin/bash", "-c"]
#CMD [ "/start.sh" ]

View File

@ -182,16 +182,3 @@ test_configs_alpine() {
test_framework_stubbing() {
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"; fi;
}
docker_main() {
IMAGE="$1"
case $IMAGE in # Setup webserver
"debian")
echo -n '::: Starting up DNS and Webserver ...'
service dnsmasq restart
service lighttpd start
gravity.sh
tail -F "${WEBLOGDIR}"/*.log /var/log/pihole.log
;;
esac
}

View File

@ -4,22 +4,23 @@ MAINTAINER adam@diginc.us <adam@diginc.us>
ENV IMAGE debian
ENV PATH /opt/pihole:${PATH}
COPY install.sh /install.sh
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.18.1.5/s6-overlay-amd64.tar.gz
ENV TINI_VERSION v0.13.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0527A9B7 && \
gpg --verify /tini.asc && \
chmod +x /tini && \
apt-get -q update && \
apt-get install -y wget net-tools && \
/install.sh && \
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'
@ -33,6 +34,7 @@ ENV IPv6 True
EXPOSE 53 53/udp
EXPOSE 80
ENV S6_LOGGING 0
ENV S6_KEEP_ENV 1
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/tini", "--"]
CMD [ "/start.sh" ]

View File

@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bash
/start.sh
gravity.sh

View File

@ -0,0 +1 @@
/etc/resolv.conf false doesntexist,0:1000 0664 0664

View File

@ -0,0 +1,7 @@
#!/usr/bin/with-contenv bash
s6-echo "Starting crond"
exec -c
fdmove -c 2 1
/usr/sbin/cron -f

View File

@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash
kill -9 $(pgrep dnsmasq)

View File

@ -0,0 +1,5 @@
#!/usr/bin/with-contenv bash
s6-echo "Starting dnsmasq"
s6-setuidgid root dnsmasq -7 /etc/dnsmasq.d --no-daemon

View File

@ -0,0 +1,5 @@
#!/usr/bin/with-contenv bash
s6-echo "Starting lighttpd"
lighttpd -D -f /etc/lighttpd/lighttpd.conf

10
s6/debian-root/usr/bin/host-ip Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/with-contenv sh
#
# This script will determine the network IP of the container.
#
# Return format should be a single IP address.
#
# Default to using the value of the $HOSTNAME ENV variable.
getent hosts ${1:-$HOSTNAME} | awk '{print $1}'

View File

@ -0,0 +1,12 @@
#!/usr/bin/execlineb -S0
if { s6-test $# -eq 2 }
backtick -in FILENAME {
pipeline { s6-echo "${1}" }
tr "a-z" "A-Z"
}
import -u FILENAME
redirfd -w 1 /var/run/s6/container_environment/${FILENAME}
s6-echo -n -- ${2}

View File

@ -27,9 +27,4 @@ if [[ ! -d "/var/run/s6/services/$service" ]] ; then
exit
fi;
if [[ "$service" == 'lighttpd' ]] ; then
echo -e "Lighttpd replaced by nginx in diginc/pi-hole:alpine\nrunning service nginx $command instead";
service='nginx'
fi;
${command} "${service}"

View File

@ -28,4 +28,4 @@ setup_ipv4_ipv6
test_configs
test_framework_stubbing
docker_main "$IMAGE"
# s6's init takes care of running services now, no more main start services function

View File

@ -10,8 +10,8 @@ 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:
#args += " -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\""
args += " -e PYTEST=\"True\""
args += " -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\""
#args += " -e PYTEST=\"True\""
docker_run = "docker run -d {} {} {}".format(args, image, cmd)
docker_id = check_output(docker_run)

View File

@ -5,10 +5,6 @@ def start_cmd():
''' broken by default, required override '''
return None
START_DNS_STDOUT = {
'alpine': '',
'debian': 'Restarting DNS forwarder and DHCP server: dnsmasq.\n'
}
@pytest.fixture
def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd):
''' Override the RunningPiHole to run and check for success of a
@ -46,5 +42,5 @@ def test_pihole_start_cmd(RunningPiHole, Dig, persist_tag, start_cmd, hostname,
lookup = RunningPiHole.dig.run(dig_cmd).stdout.rstrip('\n')
assert lookup == expected_ip
stdout = "::: Blocking has been {}d!\n{}".format(start_cmd, START_DNS_STDOUT[persist_tag])
stdout = "::: Blocking has been {}d!\n".format(start_cmd)
assert RunningPiHole.cmd.stdout == stdout