feat: add db recreation target and update Laravel setup docs

This commit is contained in:
2025-12-14 23:12:08 +03:00
parent 2c86eda6be
commit 16e98b5663
6 changed files with 43 additions and 14 deletions

View File

@@ -13,7 +13,6 @@ ARG UID
ARG GID
# Create a new user with the specified UID and GID, reusing an existing group if GID exists
# and update php-fpm to use the new user and group
RUN if getent group ${GID}; then \
group_name=$(getent group ${GID} | cut -d: -f1); \
useradd -m -u ${UID} -g ${GID} -s /bin/bash www; \

View File

@@ -9,10 +9,13 @@ if [ ! -f "artisan" ]; then
exec "$@"
fi
if [ ! -f .composer-hash ] || ! sha1sum -c .composer-hash > /dev/null 2>&1; then
gosu www mkdir -p .hashes
if [ ! -f .hashes/.composer-hash ] || ! sha1sum -c .hashes/.composer-hash; then
echo ">> composer.json or composer.lock changed, installing dependencies..."
gosu www composer install --optimize-autoloader --no-interaction
sha1sum composer.json composer.lock > .composer-hash
gosu www sha1sum composer.json composer.lock > .hashes/.composer-hash
chown www: .hashes/.composer-hash
else
echo ">> Composer dependencies up to date (hash match), skipping install."
fi
@@ -36,17 +39,19 @@ fi
echo ">> Running seeders..."
gosu www php artisan db:seed --force
if composer show knuckleswtf/scribe > /dev/null 2>&1; then
if composer show knuckleswtf/scribe >/dev/null 2>&1; then
# Define all directories/files Scribe cares about
SCRIBE_SOURCES="config/scribe.php routes/ app/Http/Controllers/ app/Http/Requests/ app/Models/"
# Create combined hash of all .php files in those paths
CURRENT_HASH=$(find $SCRIBE_SOURCES -type f -name "*.php" -exec sha1sum {} + | sha1sum)
if [ ! -f .scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .scribe-hash)" ]; then
if [ ! -f .hashes/.scribe-hash ] || [ "$CURRENT_HASH" != "$(cat .hashes/.scribe-hash)" ]; then
echo ">> Generating API documentation..."
gosu www php artisan scribe:generate --no-interaction || true
echo "$CURRENT_HASH" > .scribe-hash
gosu www php artisan scribe:generate --no-interaction \
|| echo ">> Warning: Scribe generation failed, continuing..."
echo "$CURRENT_HASH" > .hashes/.scribe-hash
chown www: .hashes/.scribe-hash
else
echo ">> API docs up to date, skipping Scribe generation."
fi