Deployment pipelines
Edit on GitHubFor performance and stability reasons, remove all heavy data ingestion or processing operations from deployment steps/install recipes. Use a Jenkins job instead and start these operations after the deployment is finished.
Spryker Cloud Commerce OS(SCCOS) provides automated CI/CD(Continuous Integration/Continuous Deployment) Pipelines based on the following AWS Code Suite services:
-
CodePipeline - Build and Deploy scenarios
-
CodeBuild - Stages of pipeline execution
Deployment pipeline types
There are two deployment pipelines: normal and destructive.
Normal deploy is a pipeline that includes all the stages of a complete CI/CD flow. You can set it to run automatically on version control system updates. The install
stage of this pipeline does not perform any dangerous data manipulations like database cleanup or scheduler reset. Use it for production deployments.
Destructive deploy is a pipeline that includes all the stages of a complete CI/CD flow. You can set it to run automatically on version control system updates. The install
stage of this pipeline resets all the data in applications. Use it for initial or non-production deployments.
Deployment stages
Regardless of the pipeline type, deployment is divided into three stages:
pre-deploy
install
post-deploy
The stages are configured as CodeBuild projects in AWS.
Each stage is configured to execute a set of commands. The configuration is based on two files:
-
buildspec.yml
provides the default configuration of SCCOS. This is a CodeBuild configuration file that is used if no custom configuration is provided for a stage. -
deploy.yml
provides a custom configuration overwritingbuildspec.yml
. This file is located in the project repository root.
Deploy file name depends on the project and environment you are working with.
The variables in the image: environment:
section of deploy.yml
are injected into the Docker image built with Spryker Docker SDK.
...
image:
tag: spryker/php:8.0-alpine3.16
environment:
SPRYKER_DEFAULT_STORE: "US"
SPRYKER_ACTIVE_STORES: "US"
SPRYKER_HOOK_BEFORE_DEPLOY: "vendor/bin/install -r US/pre-deploy -vvv"
SPRYKER_HOOK_AFTER_DEPLOY: "true"
SPRYKER_HOOK_INSTALL: "vendor/bin/install -r US/production --no-ansi -vvv"
SPRYKER_HOOK_DESTRUCTIVE_INSTALL: "vendor/bin/install -r US/destructive --no-ansi -vvv"
...
Any shell commands specified in environment variables as hooks are executed with a shell inside the CodeBuild runtime. For example:
...
environment:
SPRYKER_HOOK_BEFORE_DEPLOY: “touch /some/file && echo OK || echo FAIL“
SPRYKER_HOOK_AFTER_DEPLOY: “curl http://some.host.com:<port>/notify“
SPRYKER_HOOK_INSTALL: “chmod +x ./some_custom_script.sh && ./some_custom_scipt.sh“
SPRYKER_HOOK_DESTRUCTIVE_INSTALL: “vendor/bin/install -r destructive --no-ansi -vvv“
...
Pre-deploy stage
The pre-deploy
stage is configured as a pre-deploy hook.
The command or a shell script executed during the pre-deploy
stage are set in image: environment: SPRYKER_HOOK_BEFORE_DEPLOY:
.
The default command is vendor/bin/install -r pre-deploy -vvv
.
The CodeBuild project of this stage is named Run_pre-deploy_for_<project_name>
. It uses the currently running application image in the ECS cluster as an environment image, and all Zed environment variables are accessible.
The CodeBuild project of the pre-deploy hook uses a currently running application image. If you add a new command to the hook, it is added to the hook during the next deployment. So, after updating the hook’s configuration, the command only runs starting from the second deployment.
The default configuration in buildspec.yml
looks as follows:
Install stage
The install
stage is configured as an install script.
Depending on the pipeline type, the install
stage command or script is specified in the following variables in deploy.yml
:
-
normal:
image: environment: SPRYKER_HOOK_INSTALL:
-
destructive:
image: environment: SPRYKER_HOOK_DESTRUCTIVE_INSTALL:
The CodeBuild project of this stage is named Run_install_for_<project_name>
. The currently built Docker image is used as the environment image and all Zed environment variables are accessible.
The default configuration in buildspec.yml
looks as follows:
production
and destructive
refer to the production.yml
and destructive.yml
install scripts respectively. By default, they are located in config/install
.
Post-deploy stage
post-deploy
stage is configured as a post-deploy hook.
The command or shell script of the post-deploy
stage is set in image: environment: SPRYKER_HOOK_AFTER_DEPLOY:
.
The CodeBuild project of this stage is named Run_post-deploy_for_<project_name>
. The currently active image is used as the environment image of CodeBuild project and all Zed environment variables are accessible.
The default command just returns true
during the post-deploy
stage. The default configuration in buildspec.yml
looks as follows:
Deployment diagram
Schematically, deployment in Spryker Cloud Commerce OS looks as follows.
Deployment flow diagram
Next steps
Thank you!
For submitting the form