update docker to support reporting

This commit is contained in:
sadnub 2023-10-25 23:30:20 -04:00
parent 52740271d9
commit b3ba34d980
4 changed files with 39 additions and 4 deletions

View File

@ -1,7 +1,8 @@
FROM nginxinc/nginx-unprivileged:stable-alpine
ENV PUBLIC_DIR /usr/share/nginx/html
ENV TACTICAL_DIR /opt/tactical
ENV TACTICAL_READY_FILE ${TACTICAL_DIR}/tmp/tactical.ready
USER root
RUN deluser --remove-home nginx \

View File

@ -2,6 +2,15 @@
#
# https://www.freecodecamp.org/news/how-to-implement-runtime-environment-variables-with-create-react-app-docker-and-nginx-7f9d42a91d70/
#
set -e
function check_tactical_ready {
sleep 15
until [ -f "${TACTICAL_READY_FILE}" ]; do
echo "waiting for init container to finish install or update..."
sleep 10
done
}
# Recreate js config file on start
rm -rf ${PUBLIC_DIR}/env-config.js
@ -26,3 +35,28 @@ EOF
)"
echo "${nginx_config}" > /etc/nginx/conf.d/default.conf
check_tactical_ready
URL_PATH="${TACTICAL_DIR}/tmp/web_tar_url"
AGENT_BASE=$(grep -o 'AGENT_BASE_URL.*' /tmp/settings.py | cut -d'"' -f 2)
WEB_VERSION=$(grep -o 'WEB_VERSION.*' /tmp/settings.py | cut -d'"' -f 2)
# add dynamic web tar if configured
if [ -f "$URL_PATH" ]; then
START_STRING=$(head -c ${#AGENT_BASE} "$URL_PATH")
if [ "$START_STRING" == "${AGENT_BASE}" ]; then
echo "Attempting to pull dynamic web tar from ${AGENT_BASE}"
webtar="trmm-web-v${WEB_VERSION}.tar.gz"
wget -q $(cat "${URL_PATH}") -O /tmp/${webtar}
tar -xzf /tmp/${webtar} -C /tmp/
rm -rf ${PUBLIC_DIR}/*
mv /tmp/dist/* ${PUBLIC_DIR}
rm -f /tmp/${webtar}
rm -rf /tmp/dist
chown -R nginx:nginx /etc/nginx && chown -R nginx:nginx ${PUBLIC_DIR}
echo "Success!"
fi
fi

View File

@ -48,7 +48,7 @@ COPY --from=CREATE_VENV_STAGE ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# install deps
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends rsync && \
apt-get install -y --no-install-recommends rsync weasyprint && \
rm -rf /var/lib/apt/lists/* && \
groupadd -g 1000 "${TACTICAL_USER}" && \
useradd -M -d "${TACTICAL_DIR}" -s /bin/bash -u 1000 -g 1000 "${TACTICAL_USER}"

View File

@ -118,6 +118,7 @@ EOF
python manage.py pre_update_tasks
python manage.py migrate --no-input
python manage.py generate_json_schemas
python manage.py get_webtar_url > ${TACTICAL_DIR}/tmp/web_tar_url
python manage.py collectstatic --no-input
python manage.py initial_db_setup
python manage.py initial_mesh_setup
@ -127,7 +128,6 @@ EOF
python manage.py create_natsapi_conf
python manage.py create_uwsgi_conf
python manage.py create_installer_user
python manage.py setup_reporting_permissions
python manage.py clear_redis_celery_locks
python manage.py post_update_tasks