The Docker SDK
Edit on GitHubSpryker Docker SDK is a tool designed to help you set up a Docker environment for your Spryker project.
The tool builds a production-like Docker infrastructure for Spryker based on the provided Deploy file.
Spryker Docker SDK is used for the following purposes:
- Building production-like Docker images.
- Serving as part of a development environment based on Docker.
- Simplifying the process of setting up a local demo of Spryker project.
This document provides details on how the Docker SDK is organized internally and works under the hood.
Docker SDK repository structure
The docker-sdk repository contains the following folders:
- bin: structured sh commands that are copied and used in the containers.
- ci: Travis deployment pipeline, basic tests.
- context: service configurations, such as PHP, MySQL, nginx, etc.
- deployment: Docker images, configs, and assets generated by the Docker SDK for the current project. These artefacts are necessary for building the Spryker application containers and services.
- docs: usage documentation.
- generator: generator of the
deployment
folder. - images: Docker files for services, applications, etc.
Docker/sdk boot command details
The Docker SDK boot
command runs the generator application. The generator is deployed as a Docker container. It takes twig templates and project’s deploy.yml
with context and generates the content of the deployment folder.
The boot
command does the following:
- Prepares the env files for Glue, Zed, and Yves.
- Prepares endpoints and store-specific configs.
- Prepares the Nginx configuration for the frontend and gateway containers.
- Prepares the PHP and debug configuration.
- Prepares Terraform env files.
- Prepares Dashboard.
- Prepares the Docker image files and the
docker-compose.yml
file for local development. - Generates bash scripts used by
deploy.sh
. - Shows the list of commands that are necessary to complete installation.
Docker/sdk up command details
The Docker SDK up
command does the following:
- Prepares data in
deployment/default/deploy.sh
:- Mounts Mutagen:
- Removes the sync volume.
- Terminates Mutagen.
- Creates the volume.
- Builds app images in CLI with the
docker/sdk build
command. - Tags application images with the
docker/sdk tag
command. - Mounts codebase with the following commands:
install composer
install -s build
build-{mode}
- Mounts assets with the following commands:
install -s build-static
build-static-{mode}
- Builds frontend and gateway containers from an Nginx image.
- Mounts Mutagen:
- Runs containers:
- Runs before stack.
- Runs containers.
- Runs after stack.
- Loads data for each region:
- Skips if the database is not empty. If you provide the
--data
argument, then the command is “forced”. - Installs and configures RabbitMQ on broker container with the
rabbitmqctl add_vhost …
command. - Suspends scheduler and waits for job termination.
- Initiates storages for each store with the
install -s init_storages_per_store
command. - If the database does not exist, creates it on MySQL or PostreSQL container.
- Skips if the database is not empty. If you provide the
- Starts a scheduler for each region and store with the
install -s scheduler-setup
command.
Docker/sdk working mode commands
In the testing mode, you can use the docker/sdk testing
and docker/sdk (up|start) -t
commands.
The docker/sdk testing
command does the following:
- Sets the
SPRYKER_TESTING_ENABLE
variable in the frontend, gateway, and app containers. - Builds and runs the webdriver container if it does not exist.
- Stops the scheduler to ensure isolation and control.
- Runs the CLI container and executes the requested command.
The docker/sdk (up|start) -t
command does the following:
- Sets the
SPRYKER_TESTING_ENABLE
variable in the frontend, gateway, and app containers. - Builds and runs the webdriver container if it does not exist.
- Stops the scheduler to ensure isolation and control.
- Executes the
docker/sdk cli -t ...
command to enter CLI container in the test mode or to run commands.
To leave the testing mode, run docker/sdk up|start
. This command shuts down the web driver and starts the scheduler again.
In the debug mode, you can run the docker/sdk cli -x
command. This command sets the SPRYKER_XDEBUG_ENABLE
variable to allow CLI debugging.
Debugging from your browser by adding a cookie to the HTTP request works automatically.
Other docker/sdk commands
The docker/sdk run
or start
command does the following:
- Executes the
docker-compose up -d
command. - Executes the
docker-compose restart
command that restarts the frontend and gateway containers. - Waits until the services are up and running.
The docker/sdk stop
command stops running containers with the docker-compose stop
command.
The docker/sdk restart
command does the following:
- Executes the
docker/sdk stop
command. - Executes the
docker/sdk start
command.
The docker/sdk install
command prints information about what you should do to complete the installation. For example, it shows information about how to add hosts to the /etc/hosts
file, warns about incompatible OS or software, etc.
The docker/sdk down
command executes docker-compose down
, which stops and removes containers and networks.
The docker/sdk prune
command does the following:
- Executes the
docker-compose down -v
command. - Executes the
docker prune
command for images, volumes, system, and builder.
The docker/sdk reset
command does the following:
- Executes
docker-compose down -v
- Executes
docker/sdk up --build --assets --data --jobs
The docker/sdk clean-data
command stops and removes the following containers and volumes with docker-compose down -v
:
- Logs
/data
folder for Zed, Yves, and Glue- Broker data:
/var/lib/rabbitmq
- Session and key-value data:
/data
- Search data:
/usr/share/elasticsearch/data
- Scheduler data
The docker/sdk trouble
command does the following:
- Executes
docker-compose down
. - Cleans sync volumes for
docker-sync
.
The docker/sdk build
command builds the following data:
- Images: executes the
docker build
command for app and Nginx images; builds codebase and assets. - Codebase: executes
composer install
,install -s build
,build-{mode}
. - Assets: executes
install -s build-static
,build-static-{mode}
.
The docker/sdk pull
command executes docker-compose pull
, which pulls all the external images, based on docker-compose.yml
.
The docker/sdk demo
command does the following:
- Executes the
docker-compose up -d
command. - Runs the demo data installation process for each region.
The docker/sdk export images {tag}
command is only for the baked mode. It does the following:
- Builds and tags docker application images.
- Based on assetsBuilder and CLI image, builds the assets builder docker image. Runs
vendor/bin-install -s build-static build-static-{mode}
. - Builds and tags frontend images.
- Prints information about the built images.
The docker/sdk robot-framework {command}
command executes sets of API and UI tests, built on the Robot Framework.
Development environment
The following schema illustrates the development environment with the Docker SDK:
Depending on the Spryker version used, instead of zed_eu
, you can have the following containers: backoffice_eu
, backend_gateway_eu
, and backend_api_eu
.
In the development environment, Gateway (Nginx) does the following:
- Accepts all public HTTP requests.
- Handles SSL connections.
- Serves all non-application services.
- Proxies application calls to Frontend (Nginx).
Frontend (Nginx) is an HTTP to FastCGI proxy for Glue, Yves, Zed, and serves assets.
Docker/sdk debug mode
The following schema illustrates the Docker/sdk debug mode:
Docker/sdk in SCCOS
The following schema illustrates how Docker/sdk is used in the Spryker Cloud Commerce OS (SCCOS):
Docker images
The following schemas illustrate the Docker images:
Docker images and containers:
Extending Docker/sdk
To extend Docker/sdk, you can do the following:
-
To use a custom PHP or Nginx image and add extensions or libraries, you can change the application image:
environment: docker.dev image: tag: spryker/php 8.0 tag: registry.gitlab.com/my-company/spryker:1.0-php8debsap
This approach is compatible with SCCOS, but provides limited customization possibilities.
-
To introduce “mocks” for development and CI/CD testing, you can use the Docker-compose extension:
docker: compose: yamls: - {custom_compose_file_name}
This approach works for development and CI/CD only, but it’s not compatible with SCCOS setup.
Thank you!
For submitting the form