Leggi questo articolo in italiano: click here
This guide is for a single frontend node and is not fully optimized. The configuration is for
Staging but we use only staging environment.
This is an implementation of Magento Pipeline Guidelines: https://devdocs.magento.com/guides/v2.2/config-guide/deployment/pipeline/
Magento Version: >= 2.2.x
Follow this project to have an example: https://gitlab.com/gm-public/magento2-sample-deploy/pipelines
- gitlab account
- magento project with a local setup (so you have a config.php on your repository)
- ssh access of deployment server
- you know how deployer php works https://deployer.org/
Create a deploy ssh-key to access to your server
ssh-keygen -t rsa -b 4096 -N '' -f my_ssh_key
Create an ssh-keyscan of your server
ssh-keyscan -t rsa magento.staging > server_keyscan.txt
Add public deploy ssh key to the server
ssh-copy-id -i my_ssh_key.pub [email protected]
Create the project folder on the server
ssh admin[email protected] mkdir /home/admin/magento mkdir /home/admin/magento/bucket
Add Gitlab Variables for Pipeline
Settings > CI/CD > Variables and add these variables:
For Stage environment
STAGE_HOST -> ip or domain of your web machine (ex.
STAGE_HOST_DEPLOY_PATH -> absolute path where you put your source code (ex.
STAGE_SSH_KEYSCAN -> output of the file
STAGE_SSH_PRIVATE_KEY -> output of the file
STAGE_USER -> ssh user for server access (in our example
Add gitlab pipeline files in your project
Use this project to add Gitlab Pipeline: https://github.com/gmdotnet/magento2-pipeline-deploy
Settings > CI/CD > General pipelines settings and add
Custom CI config path
In this case pipeline start only with develop branch. In any case, we need to have .gitlab-ci.yml on default branch (master) or the pipeline doesn't start Also, first deploy/release will fail because we don't have any setup completed in the server
Create/compile Magento env.php on server
Once fist deploy (with error) is finished you have this folder tree:
/home/admin/magento /home/admin/magento/bucket /home/admin/magento/current /home/admin/magento/pipelines /home/admin/magento/releases /home/admin/magento/shared
/home/admin/magento/shared/htdocs/app/etc/env.php to make your magento setup.
Try to re-deploy. This time you can have the pipeline completed.
- create a system for multinode web server
- managing in a secure way ssh private key
Improve the project
Send me a feedback
Write me a line or open an issue on github.GitHub