replace lighttd with nginx

This commit is contained in:
0x5f3
2022-08-05 13:21:53 +00:00
parent 8650c68801
commit 9ac289a969
3 changed files with 23 additions and 11 deletions

View File

@@ -7,15 +7,14 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 TZ=Europe/London PORT=20211
# Todo, do we still need all these packages? I can already see sudo which isn't needed # Todo, do we still need all these packages? I can already see sudo which isn't needed
RUN apt-get update \ 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 python3 iproute2 nmap python3-pip zip -y \ && apt-get install --no-install-recommends ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip -y \
&& pip3 install requests \ && pip3 install requests \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \
&& apt-get clean autoclean \ && apt-get clean autoclean \
&& apt-get autoremove \ && apt-get autoremove \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/www/html \ && rm -rf /var/www/html \
&& ln -s /home/pi/pialert/front /var/www/html \ && ln -s /home/pi/pialert/front /var/www/html
&& lighttpd-enable-mod fastcgi-php
# now creating user # now creating user
@@ -31,13 +30,12 @@ COPY . /home/pi/pialert
# Pi.Alert # Pi.Alert
RUN python /home/pi/pialert/back/pialert.py update_vendors \ RUN python /home/pi/pialert/back/pialert.py update_vendors \
&& sed -ie 's/= 80/= '${PORT}'/g' /etc/lighttpd/lighttpd.conf \ && rm /etc/nginx/sites-available/default \
&& ln -s /home/pi/pialert/install/default /etc/nginx/sites-available/default \
&& sed -ie 's/listen 80/listen '${PORT}'/g' /etc/nginx/sites-available/default \
&& (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab - && (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab -
# it's easy for permissions set in Git to be overridden, so doing it manually # it's easy for permissions set in Git to be overridden, so doing it manually
RUN chmod -R a+rxw /home/pi/pialert/ RUN chmod -R a+rxw /home/pi/pialert/
# keep backward-compatibility with old links using <url>/pialert as a base (remove in 2023)
RUN ln -s /home/pi/pialert/front /var/www/html/pialert
CMD ["/home/pi/pialert/dockerfiles/start.sh"] CMD ["/home/pi/pialert/dockerfiles/start.sh"]

View File

@@ -7,9 +7,11 @@ if [ -n "${TZ}" ]; then
sed -ie "s|Europe/Berlin|${TZ}|g" /home/pi/pialert/config/pialert.conf sed -ie "s|Europe/Berlin|${TZ}|g" /home/pi/pialert/config/pialert.conf
crontab < /home/pi/pialert/install/pialert.cron crontab < /home/pi/pialert/install/pialert.cron
fi fi
if [ -n "${PORT}" ]; then if [ -n "${PORT}" ]; then
sed -ie 's/= 20211/= '${PORT}'/g' /etc/lighttpd/lighttpd.conf sed -ie 's/listen 20211/listen '${PORT}'/g' /etc/nginx/sites-available/default
fi fi
/etc/init.d/lighttpd start /etc/init.d/php7.4-fpm start
/etc/init.d/nginx start
cron -f cron -f

12
install/default Normal file
View File

@@ -0,0 +1,12 @@
server {
listen 80 default_server;
root /var/www/html;
index index.php;
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}