Compare commits

..

1 Commits

Author SHA1 Message Date
Lance Pioch
7a41804097 docker: fix healthcheck so the HTTP check actually runs
The condition '[ ${SKIP_CADDY} ! "true" ]' is invalid test syntax and
evaluated false in every configuration, so the curl check against /up
never ran and only php-fpm's FCGI socket was verified. A wedged Caddy or
fatally erroring app still reported healthy.

Also probe every 30s instead of 5m so failures are detected promptly, and
raise start-period to 2m since boot runs migrations and filament:optimize.
2026-07-15 20:33:08 -04:00
4 changed files with 19 additions and 41 deletions

View File

@@ -93,7 +93,7 @@ COPY docker/crontab /etc/crontabs/crontab
COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/healthcheck.sh /healthcheck.sh
HEALTHCHECK --interval=5m --timeout=10s --start-period=5s --retries=3 \
HEALTHCHECK --interval=30s --timeout=10s --start-period=2m --retries=3 \
CMD /bin/ash /healthcheck.sh
EXPOSE 80 443

View File

@@ -99,7 +99,7 @@ COPY docker/crontab /etc/crontabs/crontab
COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/healthcheck.sh /healthcheck.sh
HEALTHCHECK --interval=5m --timeout=10s --start-period=5s --retries=3 \
HEALTHCHECK --interval=30s --timeout=10s --start-period=2m --retries=3 \
CMD /bin/ash /healthcheck.sh
EXPOSE 80 443

View File

@@ -4,36 +4,19 @@
# check for .env file or symlink and generate app keys if missing
if [ -f /pelican-data/.env ]; then
echo ".env vars exist."
# load specific env vars from .env used in the entrypoint if they are not already set
for VAR in APP_KEY APP_INSTALLED DB_CONNECTION DB_HOST DB_PORT TRUSTED_PROXIES; do
# load specific env vars from .env used in the entrypoint and they are not already set
for VAR in "APP_KEY" "APP_INSTALLED" "DB_CONNECTION" "DB_HOST" "DB_PORT" "TRUSTED_PROXIES"; do
echo "checking for ${VAR}"
# the container environment takes precedence, matching Laravel's own behavior
eval "CURRENT=\${${VAR}:-}"
if [ -n "${CURRENT}" ]; then
echo "${VAR} already set in environment, skipping"
continue
fi
# match only a real assignment at the start of a line, never comments or
# other variables that merely contain the name
if ! LINE=$(grep -m1 "^${VAR}=" .env); then
echo "didn't find variable to set"
continue
fi
## skip if it looks like it might try to execute code
case "$LINE" in
*'$('*|*'`'*)
echo "var in .env may be executable, skipping"
continue
;;
esac
echo "loading ${VAR} from .env"
# strip quotes and carriage returns so values from quoted or
# Windows-edited .env files export cleanly
export "$(echo "$LINE" | tr -d "\r\"'")"
if (grep "${VAR}" .env | grep -qE "\$\(|=\`|\$#"); then echo "var in .env may be executable or a comment, skipping"; continue; fi
# if the variable is in .env then set it
if (grep -q "${VAR}" .env); then
echo "loading ${VAR} from .env"
export "$(grep "${VAR}" .env | sed 's/"//g')"
continue
fi
## variable wasn't loaded or in the env to set
echo "didn't find variable to set"
done
else
echo ".env vars don't exist."
@@ -43,7 +26,7 @@ else
# manually generate a key because key generate --force fails
if [ -z "${APP_KEY}" ]; then
echo "No key set, Generating key."
APP_KEY="base64:$(head -c 32 /dev/urandom | base64)"
APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "APP_KEY=$APP_KEY" > /pelican-data/.env
echo "Generated app key written to .env file"
else
@@ -74,13 +57,8 @@ if [ "${APP_INSTALLED}" = "true" ]; then
echo "using sqlite database"
fi
# run migration, unless disabled (e.g. when running multiple replicas
# against the same database)
if [ "${SKIP_MIGRATIONS:-false}" = "true" ]; then
echo "Skipping migrations (SKIP_MIGRATIONS=true)"
else
php artisan migrate --force
fi
# run migration
php artisan migrate --force
php artisan p:plugin:composer
fi

View File

@@ -1,9 +1,9 @@
#!/bin/ash -e
if [ ${SKIP_CADDY} ! "true" ]; then
curl -f http://localhost/up || exit 1
if [ "${SKIP_CADDY:-false}" != "true" ]; then
curl -sf http://localhost/up || exit 1
fi
cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 2
exit 0
exit 0