Envoyer (Laracasts course)
Link
https://laracasts.com/series/envoyer
01 - The First Deployment
- Current deployment in
current
subdirectory - Keeps last 6-7 releases in
releases
directory current
is a symlink to the latest release- Web root should be set to
current/public
02 - Server Directory Structure
- Deployment steps behind the scene:
- Create new directory named after the current date and time under
releases
- Install dependencies
- Run deployment hooks, such as running migrations
- Switch symlink of
current
to the new directory
- Create new directory named after the current date and time under
storage
is a symlink too
03 - Health Checks and Rollbacks
- Healthcheck can of course only be run after activating a new release, making it available to the public
- We can manually redeploy old versions by clicking a button in the interface
04 - Deployment Hooks
- Available hooks - before and after:
- Clone New Release
- Install Composer Dependencies
- Activate New Release
- Purge Old Releases
- Can select which server(s) to run on (e.g. migrations should not be run on multiple servers)
- Variables which will be replaced in hook scripts (remove the additional spaces between the brackets) include:
{ { release } }
=> current release directory
05 - When Deployment Scripts Break
- Deployment gets canceled, a warning icon appears on the dashboard
06 - Multi-Server Deployment
- Each deployment step (e.g. the built-in or hooks) has to complete successfully on all servers, before Envoyer begins the next.
- Remember to modify hooks so they run on all servers where they are required (e.g. migrations should not be run on multiple servers)
07 - Notifications
- Notifications can be sent to:
- Whenever:
- Deployment completes (whether successfully or not)
- Post-deployment healthcheck fails
- Heartbeat fails
08 - Heartbeats
- Notifies when a scheduled task (cron job) has not run when expected.
- When using a regular cron job (i.e. configured in some user’s
crontab
), append&& curl https://beats.envoyer.io/heartbeat/XXX
to the command to ping Envoyer.&&
makes thecurl
command run only if the previous command(s) exited with code 0 (i.e. successfully). - When using Laravel, we can use the thenPing() method to request the heartbeat URL.
Alternatives
09 - Environment Management
- The “Manage environment” button allows to deploy an
.env
file across all servers. - The contents are stored in the Envoyer service, but are encrypted with a key that they do not store (so it has to be entered for each modification of the
.env
contents). - It is put in the project root on the server, and symlinked to from each new release folder.
10 - Collaborators
- Collaborators have to sign up for Envoyer before they can be invited, but they do not have to pay for the service.
- Collaborators are invited per project, using the email address they registered with.
- Invitations have to be accepted by the collaborator.
- Collaborators can deploy, modify settings, add deployment hooks and heartbeats, but cannot add additional collaborators nor delete the project.