Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add php artisan config:clear on Deployments #303

Closed
jaydrogers opened this issue Apr 5, 2024 · 0 comments
Closed

Add php artisan config:clear on Deployments #303

jaydrogers opened this issue Apr 5, 2024 · 0 comments
Labels
⚡️ Enhancement Items that are new features requested to be added.

Comments

@jaydrogers
Copy link
Member

Problem

  • We cache the config, but if there is an update, the configs will not automatically clear the cache

if [ "$DISABLE_DEFAULT_CONFIG" = "false" ]; then
# Check to see if an Artisan file exists and assume it means Laravel is configured.
if [ -f "$APP_BASE_DIR/artisan" ] && [ "$AUTORUN_ENABLED" = "true" ]; then
echo "Checking for Laravel automations..."
############################################################################
# artisan migrate
############################################################################
if [ "${AUTORUN_LARAVEL_MIGRATION:=true}" = "true" ]; then
count=0
timeout=$AUTORUN_LARAVEL_MIGRATION_TIMEOUT
while [ $count -lt "$timeout" ]; do
test_db_connection > /dev/null 2>&1
status=$?
if [ $status -eq 0 ]; then
echo "✅ Database connection successful."
break
else
echo "Waiting on database connection, retrying... $((timeout - count)) seconds left"
count=$((count + 1))
sleep 1
fi
done
if [ $count -eq "$timeout" ]; then
echo "Database connection failed after multiple attempts."
exit 1
fi
echo "🚀 Running migrations..."
if [ "${AUTORUN_LARAVEL_MIGRATION_ISOLATION:=false}" = "true" ]; then
php "$APP_BASE_DIR/artisan" migrate --force --isolated
else
php "$APP_BASE_DIR/artisan" migrate --force
fi
fi
############################################################################
# artisan storage:link
############################################################################
if [ "${AUTORUN_LARAVEL_STORAGE_LINK:=true}" = "true" ]; then
if [ -d "$APP_BASE_DIR/public/storage" ]; then
echo "✅ Storage already linked..."
else
echo "🔐 Linking the storage..."
php "$APP_BASE_DIR/artisan" storage:link
fi
fi
############################################################################
# artisan config:cache
############################################################################
if [ "${AUTORUN_LARAVEL_CONFIG_CACHE:=true}" = "true" ]; then
echo "🚀 Caching Laravel config..."
php "$APP_BASE_DIR/artisan" config:cache
fi
############################################################################
# artisan route:cache
############################################################################
if [ "${AUTORUN_LARAVEL_ROUTE_CACHE:=true}" = "true" ]; then
echo "🚀 Caching Laravel routes..."
php "$APP_BASE_DIR/artisan" route:cache
fi
############################################################################
# artisan view:cache
############################################################################
if [ "${AUTORUN_LARAVEL_VIEW_CACHE:=true}" = "true" ]; then
echo "🚀 Caching Laravel views..."
php "$APP_BASE_DIR/artisan" view:cache
fi
############################################################################
# artisan event:cache
############################################################################
if [ "${AUTORUN_LARAVEL_EVENT_CACHE:=true}" = "true" ]; then
echo "🚀 Caching Laravel events..."
php "$APP_BASE_DIR/artisan" event:cache
fi
fi

Proposed solution

  • Add php artisan config:clear before the migration
@jaydrogers jaydrogers added the 🧐 Bug: Needs Confirmation Something isn't working, but needs to be confirmed by a team member. label Apr 5, 2024
@jaydrogers jaydrogers added ⚡️ Enhancement Items that are new features requested to be added. and removed 🧐 Bug: Needs Confirmation Something isn't working, but needs to be confirmed by a team member. labels Apr 18, 2024
jaydrogers added a commit that referenced this issue Apr 22, 2024
* Update PHP patch versions to 8.1.28, 8.2.18, and 8.3.6

* Removed NGINX_USER variable

* Changed FPM-NGINX to be unprivileged

* Improved readability of health check

* Improved health check

* Simplified NGINX config

* Set cert to not be a CA cert

* Configured Apache directories for changing permissions

* Changed Apache to run as unprivileged

* Converted NGINX Unit to be unprivileged

* Dropped permissions on CLI image

* Improve UX with better healthcheck notifications

* Added empty line for easier expansion by scripts

* Refactor .env.example file in docs directory

* Remove beta notice

* Add unprivileged by default support for Docker images

* Added hetzner

* Add default configurations for unprivileged Docker images

* Update Dockerfile examples in upgrade guide

* Improved syntax highlighting

* Updated versions in README

* Renamed provided PHP ini file per #242 (comment)

* Documented PHP ini customizations. Fixes #242

* Restructured the docs

* Update redirect paths in DocumentDrivenNotFound.vue

* Updated docs on Laravel Automations script

* Update Laravel task scheduler documentation and Docker Compose example

* Update Laravel task scheduler documentation and Docker Compose example

* Update links in Laravel Automations documentation

* Update Laravel task scheduler documentation and Docker Compose example

* Update Laravel queue and Laravel Horizon documentation

* Clear config cache before running migrations. Fixes #303

* Remove comment

* Added file permissions docs

* Update Docker image migration guide

* Removed old beta docs

* Added privileges

* Update command reference documentation

* Update contributing guide with link to docs contribution instructions

* Fixed links

* Update static site generation command in service_deploy-static-site.yml

* Added helpful notes to the migration guide

* Changed format of docker-php-serversideup-set-id

* Added /var/www/html/ to chown

* Update migration guide with PHP_FPM_POOL_NAME rename

* Fix SSL keypair generation in 10-init-webserver-config.sh

* Add PHP_OPCACHE_ENABLE=1 to production environment for increased performance

* Improved get-php-versions script to accept null values and rely more on the Official PHP data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡️ Enhancement Items that are new features requested to be added.
Projects
None yet
Development

No branches or pull requests

1 participant