🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Docker: make the startup log answer the first support questions
Omega (QA)cf05e3c74abb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b293e80..b54f843 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,8 @@## 1.0.5 - Unreleased+- **Clearer Docker startup logs:** the container log now opens with the running version and a short configuration summary (database host, port, database name and user, nginx on or off, upload limit, memory mode, and the frontend URL used for login redirects), so a pasted startup log answers the first support questions by itself. The database wait reports progress every 5 attempts and, if the database never answers, fails with the host and port it tried and what to check. A failure in the migrations or permissions step now stops startup with one clear line naming the step. And nginx errors go to stderr, so they appear in `docker logs` alongside the app output instead of only in a file inside the container (access logs still go to their file). No passwords are ever printed.+ - _Files: `Docker/entrypoint.sh`, `nginx.conf`_- **Smaller Docker image:** the Python dependencies now install into a virtualenv in the builder, and the runtime copies only that venv instead of the builder's whole /usr/local, so the image no longer carries a duplicate Python interpreter and standard library. Supervisor is the pip package (4.3.0) rather than the Debian package, which also removes the system Python that package pulled in. The entrypoint waits for the database with a short Python probe instead of pg_isready, so postgresql-client is gone, and the copied packages are stripped of bytecode caches, bundled test suites, and pip itself. Behaviour is unchanged: same base image, same startup flow, same supervisor-managed nginx, gunicorn, and cron. Setuptools is no longer a direct requirement (it was build tooling), and pip builds now use a BuildKit cache mount, so rebuilds on a maintainer's machine reuse previously downloaded packages. Separately, the entrypoint now prints a Warracker banner to the container log once the app passes its health check, so a fully started container is easy to spot in the logs.- _Files: `Dockerfile`, `Docker/entrypoint.sh`, `Docker/supervisord.conf`, `docker-compose.yml`, `backend/requirements.txt`, `.dockerignore`_- **Security dependency updates:** Authlib 1.9.1 to 1.9.2, which carries the upstream security fix GHSA-f3fg-34g9-v7jx (ID-JAG access tokens are now limited to the scopes granted in the ID-JAG claim). The Python 3.15 slim base image digest was refreshed in both Dockerfile stages, and actions/checkout in the test workflow moves to v7, which by default blocks checking out fork pull requests under pull_request_target and workflow_run triggers.diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.shindex 251239d..370901a 100644--- a/Docker/entrypoint.sh+++ b/Docker/entrypoint.sh@@ -1,16 +1,47 @@#!/bin/bashset -euo pipefail-echo "=== Warracker Startup ==="-# Logging functionlog() {echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"}+# Version, read from the version checker shipped with the frontend so+# the log header always names the build that is actually starting.+APP_VERSION="unknown"+if [ -f /var/www/html/version-checker.js ]; then+ APP_VERSION=$(grep -o "currentVersion = '[^']*'" /var/www/html/version-checker.js | head -1 | cut -d"'" -f2 || true)+ if [ -z "$APP_VERSION" ]; then+ APP_VERSION="unknown"+ fi+fi++echo "=== Warracker ${APP_VERSION} ==="++# Configuration summary: the values support questions ask for first+# when a user pastes their startup log. Passwords are never printed.+DB_DISPLAY_HOST="${DB_HOST:-localhost}"+DB_DISPLAY_PORT="${DB_PORT:-5432}"+DB_DISPLAY_NAME="${DB_NAME:-warranty_db}"+DB_DISPLAY_USER="${DB_USER:-warranty_user}"+log "Database: ${DB_DISPLAY_HOST}:${DB_DISPLAY_PORT}, database ${DB_DISPLAY_NAME}, user ${DB_DISPLAY_USER}"+if [ "${DISABLE_NGINX:-false}" = "true" ]; then+ log "Web: nginx disabled, gunicorn serves directly on port 5000"+else+ log "Web: nginx on port 80, upload limit ${NGINX_MAX_BODY_SIZE_VALUE:-32M}"+fi+log "Memory mode: ${WARRACKER_MEMORY_MODE:-optimized}"+if [ -n "${FRONTEND_URL:-}" ]; then+ log "Frontend URL (used for login redirects): ${FRONTEND_URL}"+elif [ -n "${APP_BASE_URL:-}" ]; then+ log "Frontend URL (used for login redirects): ${APP_BASE_URL} (from APP_BASE_URL)"+else+ log "Frontend URL (used for login redirects): not set, the built-in default http://localhost:8080 will be used"+fi+# Database connection check (with retry). A plain TCP probe from Python# replaces pg_isready, so the image no longer needs postgresql-client.-log "Waiting for database connection..."+log "Waiting for database connection to ${DB_DISPLAY_HOST}:${DB_DISPLAY_PORT}..."for i in {1..30}; doif python -c "import os, socket, sys@@ -24,18 +55,30 @@ except OSError:breakfiif [ $i -eq 30 ]; then- log "ERROR: Database not available after 30 attempts"+ log "ERROR: Could not reach the database at ${DB_DISPLAY_HOST}:${DB_DISPLAY_PORT} after 30 attempts (about 60 seconds)."+ log "ERROR: Check that the database container is running and that DB_HOST and DB_PORT point to it, then restart this container."exit 1fi+ if [ $((i % 5)) -eq 0 ]; then+ log "Still waiting for database (attempt $i of 30)..."+ fisleep 2done-# Migrations and permissions+# Migrations and permissions. Each critical step is guarded so a+# failure stops startup with one clear line naming the step, instead+# of the script simply ending after a traceback.log "Running database migrations..."-python /app/migrations/apply_migrations.py+if ! python /app/migrations/apply_migrations.py; then+ log "ERROR: Database migrations failed, startup stopped. The messages above show the cause."+ exit 1+filog "Fixing permissions (database and upload folder)..."-python /app/fix_permissions.py+if ! python /app/fix_permissions.py; then+ log "ERROR: Fixing permissions failed, startup stopped. The messages above show the cause."+ exit 1+fi# Translation compilationlog "Compiling translations..."diff --git a/nginx.conf b/nginx.confindex b0ba16f..15af59f 100644--- a/nginx.conf+++ b/nginx.conf@@ -6,8 +6,9 @@ server {root /var/www/html;index index.html;- # Enable detailed error logging- error_log /var/log/nginx/error.log warn;+ # Send nginx errors to stderr so they appear in `docker logs`+ # alongside the app output; access logs stay in their file.+ error_log /dev/stderr warn;access_log /var/log/nginx/access.log;# Global settings