fiddle with docker

This commit is contained in:
Codex Agent
2025-11-15 17:00:57 +01:00
parent 4981d9f060
commit 5348c5b137
3 changed files with 159 additions and 107 deletions

View File

@@ -1,33 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail
APP_SOURCE=${APP_SOURCE:-/opt/app}
APP_TARGET=${APP_TARGET:-/var/www/html}
APP_USER=${APP_USER:-www-data}
APP_GROUP=${APP_GROUP:-www-data}
SKIP_CODE_SYNC=${SKIP_CODE_SYNC:-0}
mkdir -p "${APP_TARGET}"
sync_code() {
if [[ "$SKIP_CODE_SYNC" == "1" ]]; then
return
fi
# Sync the built application from the immutable image into the shared app volume
# while preserving runtime data that lives under storage/.
rsync -a --delete \
--exclude storage \
--exclude public/storage \
--exclude bootstrap/cache \
--exclude .env \
"${APP_SOURCE}/" "${APP_TARGET}/"
if [[ ! -d "$APP_TARGET" ]]; then
mkdir -p "$APP_TARGET"
fi
cd "${APP_TARGET}"
rsync -a --delete --omit-dir-times --no-perms --no-owner --no-group \
--exclude="storage/logs" \
--exclude="storage/framework/sessions" \
"$APP_SOURCE"/ "$APP_TARGET"/ || true
mkdir -p storage/framework/{cache,sessions,testing,views} storage/logs bootstrap/cache
chown -R "${APP_USER}:${APP_GROUP}" storage bootstrap/cache || true
find storage -type d -exec chmod 775 {} \;
find storage -type f -exec chmod 664 {} \;
chmod -R ug+rwx bootstrap/cache
chown -R "$APP_USER:$APP_GROUP" "$APP_TARGET"
}
php artisan config:cache --quiet || true
php artisan route:cache --quiet || true
php artisan event:cache --quiet || true
ensure_helper_scripts() {
if compgen -G "$APP_TARGET/docs/queue-supervisor/*.sh" > /dev/null; then
chmod +x "$APP_TARGET"/docs/queue-supervisor/*.sh || true
fi
}
prepare_storage() {
cd "$APP_TARGET"
if [[ ! -h public/storage ]]; then
php artisan storage:link >/dev/null 2>&1 || true
fi
if [[ -n "${PENDING_MIGRATIONS:-}" ]]; then
php artisan migrate --force >/dev/null 2>&1 || true
fi
}
sync_code
ensure_helper_scripts
prepare_storage
cd "$APP_TARGET"
exec "$@"