How to Deploy Your Code on Webscale

Information on how to deploy your code and details about how the deployment process works.

The Webscale deployment process is a modern CI/CD pipeline, with your code being managed by source control and then deployed using Docker containers. This removes the majority of downtime associated with deploying the code for a new application or website. In the past, it was necessary to set your Magento application to maintenance mode while the build processes were run, often resulting in downtimes of at least 1-2 hours. Using this modern CI/CD pipeline not only ensures little to no downtime, but also allows you to fix any problems with the site much more quickly.

This deployment process uses Docker containers and the AWS ECR container registry to take all of the code compilation steps that are part of the build process and add them to a Docker deployment script, which uses the code from your source control to build an image. This Docker image build can be run on a staging server while the production site is still live. This allows your team to test and verify the new deployment without impacting your customers. Once you’ve verified that the site builds properly, you can deploy the same image to production quickly, while all of the site’s assets are simultaneously deployed, resulting in near-zero downtime. Since a new build can be done quickly with a Docker script, any problems with the production site can be quickly resolved by simply rolling back to an older Docker image stored in the container registry.

Build process

  1. Webscale will authorize OAuth access to the AWS account for your Git repository (either GitHub, Bitbucket or GitLab).
  2. Upon a push into your Git repo, codebuild will build a container image with your code.
    • This process uses the Dockerfile to create the container image (a default Dockerfile template can be provided, if required). Note: Future images will have a “commit ID” tag by default - this comes from the Git repository.
  3. Once the container is built using the Dockerfile, the container is pushed to AWS ECR.
  4. ECR runs a vulnerability scan on the container.

Deployment process

During onboarding, Webscale will grant you access to a deployment system via SSH that is specific to the environment to which you want to deploy. Run these commands in that environment (i.e., production or staging). The following procedure provides instructions for deployment for a staging environment. In the example, the commit id is “abc123” and Git branch name is “m2stage.”

To deploy in a staging environment

SSH into the deployment system and run the following commands:

  1. Run list-images.

    • Find the container that you want to deploy in the list. The images are sorted from oldest to newest with the oldest image at the top, so that the latest built image is at the bottom.
  2. If you know your commit ID, run tag-by-commit [commit id] staging to tag the image as ready to deploy.

    -OR-

    If your environment supports tagging by branch, run tag-by-branch [branch name] staging

  3. Run the deployment script: run-deploy-and-cleanup

Example

$ list-images
"sha256:250eab59befa478121d87a06adf2745b32ceb97166d7d1fc99800785feada144": [
    "branch-m2dev",
    "commit-xyzasdf",
	"staging"
]
"sha256:035dbb834079c8103c4193ce4c6ac1609d1c2f7fdf9556635770f83dbb4e5e30": [
    "branch-m2stage",
    "commit-abc123",
]

$ tag-by-commit abc123 staging
OR
$ tag-by-branch m2stage staging

2021-08-08T08:08:08 [*docker tag*] Assigning tag staging to image [commit(abc123) digest(sha256:abcxyz456)].

$ run-deploy-and-cleanup

Waiting for servers to verify...complete
New cluster example-env-b is live. Waiting 30 seconds before cleaning up old cluster example-env-a

Deleting old servers
Done

Definitions

  • Docker container: A standard unit of software that packages code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
  • Container image: A lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
  • Dockerfile: A text document that contains all the commands a user could call on the command line to assemble an image.
  • Container registry: A collection of repositories made to store container images.
  • OAuth: An open standard for access delegation, commonly used as a way for internet users to grant websites or applications access to their information on other websites but without giving them the passwords.
  • Git: A distributed version-control system for tracking changes in any set of files, originally designed for coordinating work among programmers cooperating on source code during software development.

Further Reading

Have questions not answered here? Please Contact Support to get more help.


Last modified January 28, 2021