Various changed to docker to make CORS happy and customizable

This commit is contained in:
diginc 2016-07-07 23:34:41 -05:00
parent 492638fca2
commit d2f7043f2b
7 changed files with 48 additions and 19 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
*.swp
*.sw*
# WIP/test stuff
doco.yml

@ -1 +1 @@
Subproject commit 62e898e82c601e7f58ded01bd031e444843dd125
Subproject commit d1ef51a3589a2b3b7dfa1017f2c2c6b9d97a3788

View File

@ -26,18 +26,25 @@ COPY ./AdminLTE /var/www/html/admin
COPY ./AdminLTE_version.txt /etc/
COPY ./pi-hole_version.txt /etc/
# Things installer did
# 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 && \
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 && \
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|"cd /var/www/html/admin/ && git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php
sed -i 's|"cd /var/www/html/admin/ && git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php && \
sed -i 's|www-data|nginx|g' /etc/sudoers.d/pihole && \
/bin/true # placeholder
# This chould be eliminated if all (upstream) files were +x in git
RUN chmod +x /usr/local/bin/*.sh
@ -45,6 +52,9 @@ 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/php5/fpm.d/envs.conf'
ENV PHP_ERROR_LOG '/var/log/nginx/error.log'
COPY ./alpine/start.sh /
EXPOSE 53 53/udp

View File

@ -1,12 +1,22 @@
#!/bin/sh
if [ -n "$ServerIP" ] ; then
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
echo "$ServerIP" > /etc/pihole/piholeIP;
else
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;
echo "[www]" > $PHP_ENV_CONFIG;
echo "env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG}" >> $PHP_ENV_CONFIG;
echo "env[ServerIP] = ${ServerIP}" >> $PHP_ENV_CONFIG;
if [ -n "$VIRTUAL_HOST" ] ; then
echo "env[VIRTUAL_HOST] = ${VIRTUAL_HOST}" >> $PHP_ENV_CONFIG;
fi;
echo "Added ENV to php:"
cat $PHP_ENV_CONFIG
dnsType='default'
DNS1=${DNS1:-'8.8.8.8'}
DNS2=${DNS2:-'8.8.4.4'}

View File

@ -32,10 +32,13 @@ 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 && \
@ -51,6 +54,9 @@ 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/start.sh /
EXPOSE 53 53/udp

24
debian/start.sh vendored
View File

@ -1,12 +1,21 @@
#!/bin/sh
if [ -n "$ServerIP" ] ; then
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
echo "$ServerIP" > /etc/pihole/piholeIP;
else
if [ -z "$ServerIP" ] ; then
echo "ERROR: It is required you pass an environment variables of 'ServerIP' with the IP of your docker host which you are passing 80/53 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
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'}
@ -14,13 +23,6 @@ if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
dnsType='custom'
fi;
if [ -n "$VIRTUAL_HOST" ] ; then
PHP_CONFIG='/etc/lighttpd/conf-enabled/15-fastcgi-php.conf'
sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${VIRTUAL_HOST}\"," $PHP_CONFIG
echo "Added ENV to php:"
grep 'VIRTUAL_HOST' $PHP_CONFIG
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 && \

View File

@ -14,3 +14,4 @@ docker run -it --rm --cap-add=NET_ADMIN \
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
$@ \
diginc/pi-hole:${image:-alpine}