Skip to content

Instantly share code, notes, and snippets.

@mindfullsilence
Last active October 12, 2024 17:49
Show Gist options
  • Save mindfullsilence/5df7592ea4422f9a5724f4de3fdd19b3 to your computer and use it in GitHub Desktop.
Save mindfullsilence/5df7592ea4422f9a5724f4de3fdd19b3 to your computer and use it in GitHub Desktop.
Deployment scripts for atomic deployment of laravel applications in runcloud

Runcloud Automic Deployment Script For Laravel Applications

These scripts can be used to set up automic deployments in runcloud for laravel applications

##################################################################
# == CLEAR CACHE ==
#
# Clears all laravel caches
#
# Action: Activate New Release
# Location: Before Activate New Release
##################################################################
cd {RELEASEPATH}
# Run database migrations
php artisan migrate --force
php artisan cache:clear
# Clear expired password reset tokens
php artisan auth:clear-resets
# Clear and cache routes
php artisan route:clear
php artisan route:cache
# Clear and cache config
php artisan config:clear
php artisan config:cache
##################################################################
# == NPM ==
#
# Install and compile npm sources, regenerate composer classmap
#
# Action: Install Composer Dependencies
# Location: After Install Composer Dependencies
##################################################################
cd {RELEASEPATH}
# regenerate classmap
composer dump-autoload
# install and compile npm packages
npm install
npm run prod
##################################################################
# == END ==
#
# Brings laravel out of maintenance mode.
#
# Action: Activate Latest Release
# Location: After Activate Latest Release
##################################################################
cd {RELEASEPATH}
php artisan up
##################################################################
# == FIRST DEPLOYMENT ==
#
# NOTE: Run the below only for the first deployment to migrate and seed,
# then remove this script
#
# Action: Install Composer Dependencies
# Location: After Install Composer Dependencies
##################################################################
cd {RELEASEPATH}
php artisan migrate-fresh
php artisan db:seed
##################################################################
# == MAINTENANCE ==
#
# Puts laravel into maintenance mode.
#
# Action: Clone New Release
# Location: Before Clone New Release
##################################################################
cd {ROOTPATH}/live
php artisan down
##################################################################
# == NOVA ==
#
# OPTIONAL: Only run if you are using the laravel/nova package
#
# Action: Activate New Release
# Location: Before Activate New Release
##################################################################
cd {RELEASEPATH}
php artisan vendor:publish --provider=YourCustomNovaThemeNamespace\\YourCustomNovaTheme\\ThemeServiceProvider --force
##################################################################
# == LARAVEL SCOUT ==
#
# OPTIONAL: This script is meant to be run for sites that use the
# laravel/scout package.
#
# NOTE: Repeat the below command for every model you wish to be
# searchable via laravel scout
#
# Action: Activate New Release
# Location: Before Activate New Release
##################################################################
cd {RELEASEPATH}
php artisan tenants:run scout:import --argument="model=App\\Models\\Tenant\\User"
##################################################################
# == TENANCY FOR LARAVEL ==
#
# OPTIONAL: This script is meant to be run for sites that use the
# stancl/tenancyforlaravel package.
#
# Action: Activate New Release
# Location: Before Activate New Release
##################################################################
cd {RELEASEPATH}
php artisan tenants:migrate
@blondie63
Copy link

Hi, are you using this scripts with last Runcloud.io UI ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment