This post require to know how write and read the .yaml syntaxe only : easy ! ;)
This is the official website of automate : https://automate-deployer.com/
Automate
.automate.yml
fileFirst, add the .automate.yml
file at the root of your project (not the public directory), write this lines :
repository: [email protected]:romaricp/kit-starter-symfony-4-docker.gitplatforms:development:default_branch: mastermax_releases: 2servers:dddv-server:host: 10.128.12.12user: devpassword: %dev_password%path: /home/wwwroot/sf4preprod:default_branch: preprodmax_releases: 2servers:pddv-server:host: 10.128.12.13user: devpassword: %preprod_password%path: /home/wwwroot/sf4shared_files:- .envshared_folders:- public/uploadon_deploy:- "composer install"- "setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX var"- "setfacl -dR -m u:www-data:rwX -m u:`whoami`:rwX var"- "php bin/console c:c --env=prod --no-debug"post_deploy:- "php bin/console doctrine:schema:update --force"- "php bin/console cache:war --no-debug"
Okay so what we have write here ? It’s just setting, not coding ;)
repository: [email protected]:romaricp/kit-starter-symfony-4-docker.git
Here, we just wrote the address of your project, for example here a sample project with Symfony4.
platforms:development:default_branch: mastermax_releases: 2servers:dddv-server:host: 10.128.12.12user: devpassword: %dev_password%path: /home/wwwroot/sf4preprod:default_branch: preprodmax_releases: 2servers:pddv-server:host: 10.128.12.13user: devpassword: %preprod_password%path: /home/wwwroot/sf4
Here, we defined all servers we want to deploy our project. So as you can see, 2 servers are defined : development
and preproduction
one.
For each server we defined which git branch is used via default_branch
; so for the development
server I want to use the master
branch and for thepreprod
server I want to use thepreprod
branch.
We have to defined how many maximum releases we want to stock on each server. 2 seems good because if you get some bug after a new deployment you can rollback with one command, we will see later.
servers:pddv-server:host: 10.128.12.13user: devpassword: %preprod_password%path: /home/wwwroot/sf4
Here, we defined all servers by platform, In this case we have just one server / platform but you can easely add 2 or 3 servers to deploy your project.
For each server you have to define :
%
each side, because when you will start the deployment the terminal will ask you to enter the right password.
shared_files:- .env
Here, we defined all files shared for all releases, in this case this environment
file is for Symfony which contains all the necessary environment variables. So no matter which release is current there is just one config file for all my releases !
shared_folders:- public/upload
Here, same story with folders. We defined all folders that we need for all releases. The best example is the upload directory.
on_deploy:- "composer install"- "php bin/console c:c --env=prod --no-debug"post_deploy:- "php bin/console doctrine:schema:update --force"- "php bin/console cache:war --no-debug"
Here, it’s the list of commands lines that your project need to be deploy perfectly. There are 3 events availables with automate : pre_deploy
, on_deploy
and post_deploy
all are well explain here :
https://automate-deployer.com/doc
So now your .automate.yml file is ready !
automate.phar
Go to your root path of project
cd /your/path/project
You can download the latest version of Automate with the following command:
curl -LSs https://
Now you should get something like that :
Sample with Symfony4 project
Go to your root path of project and launch automate !
cd /your/path/project
start the deployment
Enter the dev_password
and enjoy the show ! ;)
You should get something like that :
End point of the deployment
Well if you go to our server, we should get something like that :
our development server remote
If we go to the shared directory you can see :
the shared directory
Which contain the “real” folders and files. On the other hand if we go to the current directory you can see :
The .env
file is a symbolic link to the real file .env
which is in the shared directory.
So as you can see, we deployed without a single line of code ! Automate is very easy to use and to set. Automate has a lot of plugins by default, you can see all of this to the official documentation :
https://automate-deployer.com/doc
To conclude, we can now imagine to use automate and gitlab with an automatic deployment on each merge request ! ;)
Thanks to Solène Louvrier & Nicolas Legendre for rereading. :)