Bitbucket Deployments
Much like M.D.G. IT Managed Deployments, Bitbucket pipeline deployments run Magento build steps in a separate environment, and then deploy the resulting code.
Fully containerised vs block storage
Whether deploying to persistent block storage or into containers with embedded code, the build portion of each pipeline will be identical, resulting in an artefact that comprises application code that is ready to run. Some minor differences will exist between block device and container artefacts depending on the configuration of the Managed Kubernetes Usage | File-system / Fully containerised hosting with embedded code | Persistent-storage .
In the case of block storage, application code is then deployed to a new directory in /var/www/html
which is named using the convention codebase_<pipeline_id>
. The codebase
symlink is then updated to point to that directory.
In the case of containerised deployments, the pipeline first pulls the preconfigured container from the M.D.G. IT container registry, copies code into it, and then pushes it back to the registry, applying a tag that initiates a container rollout.
In the case of Magento, both deployment methodologies then connect to SSH, check whether a setup:upgrade needs to be run, and run it if so. In both cases, there should be no downtime during a deployment unless setup:upgrade needs to be run. If this is required, the site will be briefly placed into maintenance mode while this executes.
Automation
When creating a Bitbucket pipeline, the M.D.G. IT DevOps team will be in touch to ascertain what level of automation is required with regard to triggering jobs. Generally speaking it is useful to fully automate pipelines that run on commits or merges to staging and UAT branches, so that updates to these branches are automatically applied to the associated environment. Depending on branch protections and developer workflow, deployments to production can be similarly protected, or manually triggered in Bitbucket on specific commits.
Redeploying to production
When using deployments to Fully containerised hosting with embedded code the time to run the pipeline depends significantly on the website being deployed (e.g. composer packages, themes, custom coding). With Magento we’ve seen times range from approximately 10 to 40 minutes to run the same build and deploy steps.
In the case where an application bug slips through testing and is discovered on production, 40 minutes is generally an unacceptable time for resolution. Because each version of each container (and its bundled code) is stored in the M.D.G. IT container registry, users don’t have to wait for a full build in order to redeploy the code from a previous pipeline. To do this:
Click on Pipelines in Bitbucket
Locate the successfully run pipeline that you wish to redeploy and click on the related commit SHA reference, this is located underneath the pipeline title.
Click on Run Pipeline on the bottom right hand side of the page
Select custom: redeploy-production-containers in the Pipeline drop down
Click Run
Please note that this is only available for containerised deployments — for block storage, it is sufficient to update the /var/www/html/codebase
symlink to point at the previous deployment directory.