Skip to content

Deployment procedure

Wouter Koppenol edited this page Aug 11, 2023 · 3 revisions

Deployment procedure

What exactly happens with a deployment can be found in the .github/workflows folder. But in short, this is the set of commands that are executed. Most of which speak for themselves:

php artisan readonly:enable &&
php artisan db:backup &&
php artisan up;
php artisan down --render="errors::503" --retry 60;
php artisan environment:updateprepare live &&
php artisan environment:update live &&
php artisan report:release discord &&
php artisan report:release reddit;
php artisan readonly:disable &&
php artisan up

Readonly state

In order to reduce the actual downtime of Keystone.guru when doing a release, readonly mode was introduced. During this time, no POST, PUT and DELETE requests are allowed (see app/Http/Middleware/ReadOnlyMode.php). This effectively makes the site read-only. This mode is useful for the time a database backup is performed. There's still some possibility of automated processes performing writes during this time and info getting lost, but I never had any problems with this.

DB Backup

Database backup is performed using mysqldump, and the target file is written to my personal NAS for safekeeping. This will need to be professionalized. See https://github.com/Wotuu/keystone.guru/wiki/Database-backup.

Up/down

See https://laravel.com/docs/10.x/configuration#maintenance-mode

Update prepare

This prepares the environment for update. First thing is to clear all hotfixes and pull the repository. Now that we have the latest changes, we can perform an npm install and a composer install. This is all a bit yanky, ideally I want to use PHP Deployer to do the deployments in a better way - then I can also deploy with very minimal downtime, if any. See https://github.com/Wotuu/keystone.guru/wiki/PHP-Deployer.

Update

Runs database migrations, seeders, creates a new Github release, optimizes the site, refreshes cache. You can choose the different environment between live, local, mapping, staging, testing. Some settings are different based on the environment. Debug environments require debug packages, forgo optimizations, etc. so ensure you pick the correct environment when updating to get the desired result. Generally though, you should only call this command with local to update your local working environment and that's it.

Report releases

This speaks for itself really - it puts out the release to third-parties such as Reddit, Github, Discord.

Clone this wiki locally