📜 ⬆️ ⬇️

Meet Envoyer.io (Part 1)

Envoyer is a new service from Taylor Otvall, the creator of Laravel. Now you can see a series of screencasts on Laracasts about this service. This is the first part of the description of this service.

Second part here

image
')

A bit of history


When Laravel Forge was launched by Taylor, he became a great helper in launching and managing multiple VPS, as well as deploying applications. Forge was engaged in the process of creating VPS in the cloud, managing the environment and deploying (including Git-hook-deployment) applications to the server, and made the process more accessible and simple.

But, unfortunately, Forge did not satisfy such needs as managing more complex deployment processes or deployment without downtime. Regardless of whether you were a Forge user or not, you had to use tools such as Capistrano or Chef or Ansible in order to have more features. But at the same time, it takes a lot of time to deal with these tools.


Introducing Envoyer.io


Today, Envoyer is launched to help solve the problems described above. Envoyer is a zero-downtime deploer for PHP and Laravel projects. This is a tool that connects to your server to deploy, and that uses a series of tools to ensure that all the preparatory work for deployment (for example, composer install) is performed in the background, while the previous version of the site is still working .

How does Zero-Downtime Deploy work?


If you have ever worked with Capistrano, you should already be familiar with this. Please note that this is a technical answer, so if you are not interested, you can skip this section.

Deploy on a regular system (for example, in Forge) means that there is only one folder where your project lives. Suppose there are two files: index.php and the app folder, and they are in the webroot.

 /webroot/index.php /webroot/app 


Your system will usually make a cd in this folder, execute git pull and then execute the script, which most likely includes composer install . This means that, most likely, your application will not function correctly for at least a few seconds.

And the zero-down-time system supports the system with the releases folder, which essentially stores your git history commits. Every time the system starts up, it creates a new folder in releases and clones the repository on the last commit (or the desired commit) to that folder. Then a script is launched in this folder. And only when a fully functioning project exists in a new folder, does the system change the symbolic link of the current folder to the latest release. And that's it!
And Envoyer manages everything himself. And at the end you have something like this:

 /webroot/current /webroot/releases /webroot/releases/20150316074832 /webroot/releases/20150315041251 


I note that all the folders that should be saved between releases should exist in the root of the project folder, and new symbolic links should be made to them at each deployment. If the Laravel application is deployed, then everything works out of the box.

First project with Envoyer


Ok, let's start the first project with Envoyer. Sign up for Envoyer.io by selecting the “I want to manage my own projects.” Option .
image

And this is what a dashboard looks like:
image

Add the first project


The first step is to add a project. Click the big “Add Project” button in the upper right corner.
image

You will be asked what type of new project, as well as indicate the data of Git.

View Project Dashboard


Immediately after creating a project, you can view the deshboard of a separate project.
image

Adding a new project


In the Servers tab on the dashboard, you can add a new server for the project.
image

To add a new server, you need to specify the IP address of the server, the Unix / SSH user under which Envoyer will log in, and the path where the project is stored (for example, /home/username/website.com or /var/www/website.com ) .
When you add a server, you will be given an SSH key, which you need to add to the ~/.ssh/authorized_keys file of the user you specified when adding the server.
image

And if you use Forge, add this SSH key in the SSH keys tab of the required server.

Now in the servers tab, clicking the update button, you can check the connection to the server.
image

If all goes well, the icon will turn green with the signature “Successful.”

Add current/ to current webroot in web server settings


Now, in the nginx / Apache config, you need to add current/ . If you are a user of Forge and Laravel, then you are most likely used to specify the folder /public . Now you need to specify /current/public .
image

Launch warm


Return to the dashboard project and click on the red Deploy button to complete the new deployment. A record of this will appear in the "Deployments" tab.
image

Click on the arrow next to the desired deployment and you can see all the steps of the deployment script (at the moment, this is the standard deployment script for this type of project):
image

Note that you can also view the output of all the commands that make up the script.
image

Done!


This is all for the first project! Now you have a project running using Envoyer.
PS If you want to deploy code, as soon as you have launched new commits into the Git branch, you can check the box “Deploy When Code Is Pushed” in the Project Settings / Source Control section.
image

Source: https://habr.com/ru/post/253217/


All Articles