chore: Add entrypoint.sh script for web UI Docker container + check log files only in /var/log/bunkerweb

This commit is contained in:
Théophile Diot 2024-08-08 11:55:47 +01:00
parent 80ac2f50a0
commit 6354d770e9
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
3 changed files with 28 additions and 9 deletions

View file

@ -49,6 +49,7 @@ WORKDIR /usr/share/bunkerweb
COPY src/ui/src ui/src
COPY src/ui/*.py ui/
COPY --chmod=750 src/ui/entrypoint.sh ui/
FROM python:3.12.4-alpine@sha256:7f15e22f496c65cffbbac5e30e7e98d60f3e3b9cc5ee5d51cf3c55ed604787c8
@ -58,7 +59,7 @@ RUN umask 027
# Install runtime dependencies and add ui user
RUN apk add --no-cache bash unzip libmagic mariadb-connector-c mariadb-client postgresql-client sqlite && \
addgroup -g 101 ui && \
adduser -h /var/cache/nginx -g ui -s /bin/sh -G ui -D -H -u 101 ui
adduser -h /var/cache/nginx -g ui -s /bin/bash -G ui -D -H -u 101 ui
# Fix CVEs
RUN apk add --no-cache "busybox>=1.36.1-r17" "busybox-binsh>=1.36.1-r17" "ssl_client>=1.36.1-r17" # CVE-2023-42363 CVE-2023-42364 CVE-2023-42365 CVE-2023-42366
@ -100,4 +101,4 @@ HEALTHCHECK --interval=10s --timeout=10s --start-period=30s --retries=6 CMD /usr
ENV PYTHONPATH="/usr/share/bunkerweb/deps/python"
CMD [ "python3", "-m", "gunicorn", "--config", "gunicorn.conf.py", "--user", "ui", "--group", "ui", "--bind", "0.0.0.0:7000" ]
ENTRYPOINT [ "./entrypoint.sh" ]

25
src/ui/entrypoint.sh Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
set -e
# shellcheck disable=SC1091
. /usr/share/bunkerweb/helpers/utils.sh
log "ENTRYPOINT" "" "Starting the web UI v$(cat /usr/share/bunkerweb/VERSION) ..."
# setup and check /data folder
/usr/share/bunkerweb/helpers/data.sh "ENTRYPOINT"
if [[ $(echo "$SWARM_MODE" | awk '{print tolower($0)}') == "yes" ]] ; then
echo "Swarm" > /usr/share/bunkerweb/INTEGRATION
elif [[ $(echo "$KUBERNETES_MODE" | awk '{print tolower($0)}') == "yes" ]] ; then
echo "Kubernetes" > /usr/share/bunkerweb/INTEGRATION
elif [[ $(echo "$AUTOCONF_MODE" | awk '{print tolower($0)}') == "yes" ]] ; then
echo "Autoconf" > /usr/share/bunkerweb/INTEGRATION
else
echo "Docker" > /usr/share/bunkerweb/INTEGRATION
fi
python3 -m gunicorn --config gunicorn.conf.py --user ui --group ui --bind 0.0.0.0:7000
log "ENTRYPOINT" "" "Web UI stopped"
exit 0

View file

@ -2126,7 +2126,6 @@ def cache():
@login_required
def logs():
logs_path = Path(sep, "var", "log", "bunkerweb")
syslog_path = Path(sep, "var", "log", "syslog")
files = []
if logs_path.is_dir():
@ -2134,12 +2133,6 @@ def logs():
if file.is_file():
files.append(file.name)
if not files and syslog_path.is_dir():
for file in syslog_path.glob("*.log"):
if file.is_file():
files.append(file.name)
logs_path = syslog_path
current_file = secure_filename(request.args.get("file", ""))
if current_file and current_file not in files: