frontend: Include chbase.sh in entrypoint
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2021-06-09 01:46:09 +02:00
parent 7fc860edec
commit e0dd5ea789
2 changed files with 30 additions and 1 deletions

View File

@ -19,7 +19,10 @@ EXPOSE 8080
WORKDIR /srv
ENTRYPOINT ["/srv/frontend", "--bind=:8080"]
ENTRYPOINT ["/usr/sbin/entrypoint.sh"]
CMD ["--bind=:8080"]
COPY entrypoint-frontend.sh /usr/sbin/entrypoint.sh
VOLUME /srv/htdocs-frontend/

26
entrypoint-frontend.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
CURRENT_BASE="/"
[ -n "${BASEURL}" ] || BASEURL="/"
run() {
local NEWBASE=$1
local FILE=$2
if [ -d "${FILE}" ]
then
for f in "${FILE}/"*.html "${FILE}/"*.js
do
run "${NEWBASE}" "${f}"
done
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
[ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views"
elif [ -f "${FILE}" ]
then
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g" ${FILE}
fi
}
[ "${CURRENT_BASE}" != "${BASEURL}"] && run "${BASEURL}" /srv/htdocs-frontend
exec /srv/frontend $@