CAPS04-FE-REFACTOR-2 / entrypoint.sh
ABDAN HAFIDZ
Update entrypoint.sh
ddff827 unverified
Raw
History Blame Contribute Delete
932 Bytes
#!/bin/sh
set -e
env | while IFS='=' read -r KEY VALUE; do
case "$KEY" in
*_FILE)
VAR_NAME="${KEY%_FILE}"
# kalau ENV biasa sudah ada jangan overwrite
if [ -n "$(printenv "$VAR_NAME")" ]; then
continue
fi
if [ -f "$VALUE" ]; then
export "$VAR_NAME=$(tr -d '\r\n' < "$VALUE")"
fi
;;
esac
done
# HF compatibility
if [ -n "$SPACE_HOST" ] && [ "${APP_URL:-}" = "http://localhost" ]; then
export APP_URL="https://$SPACE_HOST"
fi
if [ -n "$SPACE_HOST" ] && [ -z "${ASSET_URL:-}" ]; then
export ASSET_URL="https://$SPACE_HOST"
fi
if [ -z "${APP_KEY:-}" ]; then
export APP_KEY=$(php artisan key:generate --show --no-interaction)
fi
rm -f bootstrap/cache/config.php
php artisan config:clear
php artisan cache:clear
exec php artisan serve \
--host=0.0.0.0 \
--port="${PORT:-7860}"