added support for custom port, fixed the time zone issue caused by cron
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
|
|
||||||
# default UID and GID
|
# default UID and GID
|
||||||
ENV USER=pi USER_ID=1000 USER_GID=1000
|
ENV USER=pi USER_ID=1000 USER_GID=1000 TZ=Europe/London PORT=20211
|
||||||
|
|
||||||
# Todo, figure out why using a workdir instead of full paths don't work
|
# Todo, figure out why using a workdir instead of full paths don't work
|
||||||
# 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
|
||||||
@@ -28,12 +28,11 @@ RUN groupadd --gid "${USER_GID}" "${USER}" && \
|
|||||||
COPY . /home/pi/pialert
|
COPY . /home/pi/pialert
|
||||||
|
|
||||||
# Pi.Alert
|
# Pi.Alert
|
||||||
RUN python /home/pi/pialert/back/pialert.py update_vendors \
|
RUN sed -ie "s|TIMEZONE|${TZ}|g" /home/pi/pialert/install/pialert.cron \
|
||||||
&& sed -ie 's/= 80/= 20211/g' /etc/lighttpd/lighttpd.conf \
|
&& python /home/pi/pialert/back/pialert.py update_vendors \
|
||||||
|
&& sed -ie 's/= 80/= '${PORT}'/g' /etc/lighttpd/lighttpd.conf \
|
||||||
&& (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 -
|
||||||
|
|
||||||
EXPOSE 20211
|
|
||||||
|
|
||||||
# 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/
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
pialert:
|
pialert:
|
||||||
build: .
|
build: .
|
||||||
container_name: pialert_dev
|
container_name: pialert
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
@@ -10,6 +10,7 @@ services:
|
|||||||
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||||
- ${LOGS_LOCATION}/tmp:/home/pi/pialert/log
|
- ${LOGS_LOCATION}/tmp:/home/pi/pialert/log
|
||||||
environment:
|
environment:
|
||||||
- TZ=France/Paris
|
- TZ=Europe/London
|
||||||
- HOST_USER_ID=1036
|
- PORT=20211
|
||||||
|
- HOST_USER_ID=1000
|
||||||
- HOST_USER_GID=1000
|
- HOST_USER_GID=1000
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ The source :page_facing_up: Dockerfile is available [here](https://github.com/jo
|
|||||||
Network
|
Network
|
||||||
- You will have to probably run the container on the host network, e.g: `sudo docker run --rm --net=host jokobsk/pi.alert`
|
- You will have to probably run the container on the host network, e.g: `sudo docker run --rm --net=host jokobsk/pi.alert`
|
||||||
|
|
||||||
Port
|
Default Port
|
||||||
- The container runs on the port `:20211`.
|
- The app is accessible on the port `:20211`.
|
||||||
|
|
||||||
> Please note - the cronjob is executed every 1, 5 and 15 minutes so wait that long for all of the scans to run.
|
> Please note - the cronjob is executed every 1, 5 and 15 minutes so wait that long for all of the scans to run.
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ Port
|
|||||||
* Automated copy
|
* Automated copy
|
||||||
The docker image copies the DB once every 30 min to `/home/pi/pialert/config/pialert.db_bak`. If you have a backup already available, make sure you rename this file if you want to keep older backups before starting a new container. To restore the DB run: `cp /home/pi/pialert/config/pialert.db_bak /home/pi/pialert/db/pialert.db`
|
The docker image copies the DB once every 30 min to `/home/pi/pialert/config/pialert.db_bak`. If you have a backup already available, make sure you rename this file if you want to keep older backups before starting a new container. To restore the DB run: `cp /home/pi/pialert/config/pialert.db_bak /home/pi/pialert/db/pialert.db`
|
||||||
6. The container supports mapping to local User nad Group IDs. Specify the enviroment variables `HOST_USER_ID` and `HOST_USER_GID` if needed.
|
6. The container supports mapping to local User nad Group IDs. Specify the enviroment variables `HOST_USER_ID` and `HOST_USER_GID` if needed.
|
||||||
|
7. You can override the port by specifying the `PORT` env variable.
|
||||||
|
|
||||||
Config examples can be found below.
|
Config examples can be found below.
|
||||||
|
|
||||||
@@ -56,8 +57,9 @@ services:
|
|||||||
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||||
- ${LOGS_LOCATION}/:/home/pi/pialert/log
|
- ${LOGS_LOCATION}/:/home/pi/pialert/log
|
||||||
environment:
|
environment:
|
||||||
- TZ=France/Paris
|
- TZ=Europe/London
|
||||||
- HOST_USER_ID=1036
|
- PORT=20211
|
||||||
|
- HOST_USER_ID=1000
|
||||||
- HOST_USER_GID=1000
|
- HOST_USER_GID=1000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/home/pi/pialert/dockerfiles/user-mapping.sh
|
/home/pi/pialert/dockerfiles/user-mapping.sh
|
||||||
|
|
||||||
|
# if custom variables not set we do not need to do anything
|
||||||
|
if [ -n "${TZ}" ]; then
|
||||||
|
sed -ie "s|Europe/London|${TZ}|g" /home/pi/pialert/install/pialert.cron
|
||||||
|
crontab < /home/pi/pialert/install/pialert.cron
|
||||||
|
fi
|
||||||
|
if [ -n "${PORT}" ]; then
|
||||||
|
sed -ie 's/= 20211/= '${PORT}'/g' /etc/lighttpd/lighttpd.conf
|
||||||
|
fi
|
||||||
|
|
||||||
#chmod -R 755 /var/www/html/pialert
|
|
||||||
#chmod -R o+w /home/pi/pialert/db
|
|
||||||
/etc/init.d/lighttpd start
|
/etc/init.d/lighttpd start
|
||||||
cron -f
|
cron -f
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TZ=TIMEZONE
|
||||||
|
|
||||||
0 3 * * 1 python /home/pi/pialert/back/pialert.py update_vendors >/home/pi/pialert/log/pialert.vendors.log 2>&1
|
0 3 * * 1 python /home/pi/pialert/back/pialert.py update_vendors >/home/pi/pialert/log/pialert.vendors.log 2>&1
|
||||||
*/1 * * * * python /home/pi/pialert/back/pialert.py internet_IP >/home/pi/pialert/log/pialert.IP.log 2>&1
|
*/1 * * * * python /home/pi/pialert/back/pialert.py internet_IP >/home/pi/pialert/log/pialert.IP.log 2>&1
|
||||||
*/5 * * * * python /home/pi/pialert/back/pialert.py 1 >/home/pi/pialert/log/pialert.1.log 2>&1
|
*/5 * * * * python /home/pi/pialert/back/pialert.py 1 >/home/pi/pialert/log/pialert.1.log 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user