Merge pull request #13 from Macleykun/main

Futher optimizing Dockerfile
This commit is contained in:
jokob-sk
2022-06-22 09:27:33 +10:00
committed by GitHub
2 changed files with 14 additions and 23 deletions

View File

@@ -7,35 +7,25 @@ RUN apt-get update \
&& apt-get install --no-install-recommends ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo lighttpd php php-cgi php-fpm php-sqlite3 sqlite3 dnsutils net-tools python iproute2 -y \
&& apt-get clean autoclean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# Lighttpd & PHP
RUN mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /home/pi/pialert/install/index.html /var/www/html/index.html \
&& lighttpd-enable-mod fastcgi-php
&& ln -s /home/pi/pialert/front /var/www/html/pialert \
&& lighttpd-enable-mod fastcgi-php
# Redirect for lighthttpd to work properly
COPY . /home/pi/pialert
# Todo, is this tar part still needed?
# delete .git/ files and the tar/ realese directory to make the image smaller
#RUN rm -r /home/pi/pialert/.git \
RUN rm -r /home/pi/pialert/tar
# Todo, do we need to restart lighthttpd?
# Pi.Alert
RUN ln -s /home/pi/pialert/front /var/www/html/pialert \
# Pi.Alert | also we probably should/can delete the tar from the repo and remove this line
RUN rm -r /home/pi/pialert/tar \
&& python /home/pi/pialert/back/pialert.py update_vendors \
&& (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab - \
&& chgrp -R www-data /home/pi/pialert/db \
&& chmod -R 770 /home/pi/pialert/db \
# changing the default port number 80 to something random, here 20211
&& sed -ie 's/= 80/= 20211/g' /etc/lighttpd/lighttpd.conf \
&& service lighttpd restart
&& (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab -
EXPOSE 20211
# Todo, can we just use CMD and ENTRYPOINT instead of a script?
# https://github.com/rtsp/docker-lighttpd/blob/main/Dockerfile
# > this one maybe better? https://hub.docker.com/r/jitesoft/lighttpd
# Todo, refacto CMD so that we can run lighttpd and make it respond instant
# The above Dockerfile is doing this well, but i don't see why it isn't working for us
CMD ["/home/pi/pialert/dockerfiles/start.sh"]
CMD ["/home/pi/pialert/dockerfiles/start.sh"]

View File

@@ -1,4 +1,5 @@
#!/bin/sh
chmod -R o+w /home/pi/pialert/db
/etc/init.d/lighttpd start
service cron start && tail -f /dev/null
service cron start && tail -f /dev/null