Deploy script
Every project keeps the samedeploy file in its root and runs it on the server in the project directory:
deploy.conf next to it, the deploy file itself is never edited.
Current version: 1.0.0. Check the version of a project with:
Installation
The script ships with CrudAdmin, every version of it is committed incrudadmin/crudadmin. Publish it into the root of the project and commit it:
--force. deploy.conf of the project stays untouched. Projects on CrudAdmin 5 and older copy the file from a project which has it.
Steps
A failed step stops the deploy, except the steps below. The deploy goes on without them, lists them at the end and exits with
1:
optimizefails, usually on a closure in a config file. The script caches only the routes, views and events then.- The project calls
env()outside of the config files. The script removes the cached config,env()would returnnullwith it. - Restarting a queue, Horizon, Reverb or Pulse fails.
Queue workers
queue:restart only asks the running workers to stop after their current job. A process monitor starts them again with the new code, Supervisor on our servers. Keep its config in the project, e.g. project-supervisor.conf, and run the workers with the PHP version of the project:
project-supervisor.conf
Octane
The script reloads the workers of Laravel Octane when the project requireslaravel/octane and the server runs. When it does not run, the deploy says so and goes on.
Project settings
deploy.conf in the project root is a bash file read before the first step. Commit it with the project. It is optional, most projects need none.
Hooks are bash functions defined in
deploy.conf: deploy_before runs before git pull, deploy_before_npm and deploy_after_npm around the frontend build, deploy_after at the end.
deploy.conf
deploy.conf
deploy.conf win over them:
Versions
Raise the version in
src/Resources/deploy/deploy of crudadmin and add a row here with every change of the script.
php artisan optimize
CrudAdmin 6 supportsphp artisan optimize; projects on older versions deployed without it. Without the caches every request loads all config files and route files and discovers the admin models again.
A cached config has two rules, the whole list is in Config cache:
- Config files contain no closures,
config:cachefails on them. env()is called only in config files. The.envfile is not loaded with a cached config, soenv()returnsnulleverywhere else.
localizedRoutes() cache their routes too, they are registered once for every language. Run optimize again after a language is added.
php artisan admin:upgrade:cache of crudadmin/upgrade lists both in a project. Change the .env file on the server only together with a new php artisan optimize, the cached config keeps the old values until then.