Files
docker-ara/docker/entrypoint.sh
Aaron Guise 41d0f13ba8
All checks were successful
CI / build (push) Successful in 13s
CI / release (release) Successful in 11m54s
feat: Add JSON structured logging and fix mariadb-devel package name
2026-02-21 21:04:08 +13:00

53 lines
2.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -e
# ---------------------------------------------------------------------------
# Timezone — controls when crond fires, not just ARA display times.
# Set TZ at runtime, e.g.: -e TZ=Pacific/Auckland
# Defaults to UTC if not set.
# ---------------------------------------------------------------------------
TZ="${TZ:-UTC}"
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime
echo "${TZ}" > /etc/timezone
export TZ
# ---------------------------------------------------------------------------
# Configurable retention period (days) override via environment variable
# Default: 30 days
# ---------------------------------------------------------------------------
PRUNE_DAYS="${ARA_PRUNE_DAYS:-30}"
# ---------------------------------------------------------------------------
# Cron schedule for pruning override via environment variable
# Default: daily at 02:00
# ---------------------------------------------------------------------------
PRUNE_CRON="${ARA_PRUNE_CRON:-0 2 * * *}"
# ---------------------------------------------------------------------------
# Write the cron job
# Uses `ara playbook prune` with the offline client so it talks directly
# to the same database without needing a running HTTP server.
# ARA_BASE_DIR is inherited from the container environment.
# ---------------------------------------------------------------------------
echo "${PRUNE_CRON} /usr/local/bin/ara playbook prune \
--client offline \
--days ${PRUNE_DAYS} \
--limit 9000 \
--confirm >> /proc/1/fd/1 2>&1" \
| crontab -
# Start the cron daemon in the background
crond -n &
# ---------------------------------------------------------------------------
# Run DB migrations then start gunicorn
# ---------------------------------------------------------------------------
/usr/local/bin/ara-manage migrate
exec python3 -m gunicorn \
--workers="${ARA_GUNICORN_WORKERS:-4}" \
--access-logfile - \
--logger-class json_logger.JsonLogger \
--bind "[::]:${ARA_PORT:-8000}" \
ara.server.wsgi