This project contains scripts and configurations for making it easier to work with Adobe's Commerce Cloud servers and Magento docker local environments. This is what I use personally and I hope you find them useful.
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
This project is a combination of tools and scripts for working with Magento/Adobe Cloud Commerce server environments and the Magento Cloud Docker project for local development. The project contains helpful tools for doing the following in each environment:
- Replicating an environment into another environment. For example, you may want to setup staging with the latest images and data from production in order to test a new feature. Magento Cloud currently does not have an easy way of doing this, developers must create there own scripts to accomplish this.
- Flush the cash on a given environment
- Fully reindex a given environment
- Download the database from a local environment
- Get the latest configuration dump from a given environment
- Run the bin/magento command on a given environment
- Sync only images from one environment into another environment
- Replicate and import the database from one environment into another environment
- Create a db dump export on a remote environment for development
- Download a copy of the app/etc/env.php file from a given environment
- Create a remote db backup of a given environment and store it locally
- Create a remote media backup of a given environment and store it locally
- Initialize a local Magento Cloud Docker environment that's an exact replica, including database and images, of a remote Magento Cloud Commerce environment
- Run the deployment process on a local Magento Cloud Docker environment
- Run validation tests on your local environment to ensure that it has the correct tools and files to sucessuflly set up a local Magento Cloud Docker environment
- Run the composer command on the local Magento Cloud Docker environment
- Run the magento command on the local Magento Cloud Docker environment
- kvz/bash3boilerplate
- This project provided templates for creating bash scripts that provided argument parsing and validation, debugging, and logging .
- markshust/docker-magento
- This provided inspiration for how to structure much of the code. I also utilized some scripts directly from within this project.
- tlatsas/bash-spinner
- This project provided for an easy way to display a spinner to the user during script execution. This was needed in order to show during project initialization that a source database was imported.
- jasperes/bash-yaml
- This project provided an easy way to work with yaml within bash scripts. This script helped establish the general project configuration at project.ini.dist
The requirements for configuring the project will vary depending on if you just want to work with remote Magento Cloud environments or if your also trying to create a local Magento Docker environment based on a Magento Cloud environment. The following instructions will assume that you will both want to use docker for local development and work with remote environments at the same time. This project has only been tested within linux environments.
- Clone the repo
git clone https://github.com/carlos-reynosa/adobe-commerce-cloud-and-docker-tools.git
- Setup the project configuration file by providing values to connect to the remote Magento Commerce Cloud Project and code. See the next section for variable meanings.
cp project.ini.dist project.ini
- Install the magento-cloud client tool using the instructions on their website.
- Make sure you have docker installed within your local environment according to Adobe's instructions on their website.
- Run the local environment validation script to check if you have the project set up for working with Magento Cloud and the Magento Docker project locally.
bin/docker/local-environment/validation-test
- Direction in which the main project code will exist. Example: app
- Magento Commerce Project ID used to identify your particular Commerce Cloud project when establishing a connection
- Custom cloud variable name used to force a redeployment within an environment and that will also skip cache
- Local host domain used for accessing the local docker development environment. Example test.m2.test
- Non Magento Commerce Cloud repo used for managing and storing the application code. This is for use when the Commerce Cloud git repo is only used for publishing changes.
- Magento Commerce Cloud git repo URL used for publishing application code into an environment
- Vendor package name in the form of vendor/package used for configuring grunt static file generation
- Theme name used for local theme development and static file generation with grunt.
- Replicate and import the database from one environment into another environment
- Example: Reinitialize the staging environment with data from source environment production
bin/cloud/sync-environment-db -e staging -s production
- Example: Reinitialize the feature-a environment branch with data from feature-b source environment branch
bin/cloud/sync-environment-db -e feature-a -s feature-b-environment-branch
- Example: Reinitialize the staging environment with data from source environment production
- Sync media from one environment into another environment
- Example: Grab the latest media files from production into staging
bin/cloud/sync-environment-media -e staging -s production
- Example: Grab the latest media files from production into staging
- Replicating an environment into another environment. For example, you may want to setup staging with the latest images and data from production in order to test a new feature. Magento Cloud currently does not have an easy way of doing this, developers must create there own scripts to accomplish this.
- Example: Reinitialize the staging environment with data from source environment production
bin/cloud/sync-environment-db -e staging -s production
- Example: Reinitialize the feature-a environment branch with data from feature-b source environment branch
bin/cloud/sync-environment-db -e feature-a -s feature-b-environment-branch
- Example: Reinitialize the staging environment with data from source environment production
- Flush the cash on a given environment
- Example: Flush the cache on integration
bin/cloud/cashe-flush -e integration
- Example: Flush the cache on integration branch feature-a-integration-branch
bin/cloud/cashe-flush -e feature-a-integration-branch
- Example: Flush the cache on integration
- Fully reindex an environment
- Example: Reindex integration
bin/cloud/full-reindex -e integration
- Example: Reindex integration
- Run the magento command on a given environment
- Example: List available magento commands within integration
bin/cloud/magento -e integration -a 'list'
- Example: List available magento commands within integration
- Create a db dump on an environment and store it within it's file directory at /tmp
- Example: Create a db dump for development on integration
bin/cloud/create-remote-sync-db-dump -e integration
- Example: Create a db dump for development on integration
- Download the database from an environment into your docker project configuration for initialization
- Example: Get a db dump from integration and place it in the local project docker directory for docker initialization import at .docker/mysql/docker-entrypoint-initdb.d/
bin/cloud/get-db-for-docker -e integration
- Example: Get a db dump from integration and place it in the local project docker directory for docker initialization import at .docker/mysql/docker-entrypoint-initdb.d/
- Get the latest configuration dump from a given environment
- Example: Grab the application configuration dump from staging and store it in the local project
bin/cloud/get-latest-config - e staging
- Example: Grab the application configuration dump from staging and store it in the local project
- Download a copy of the app/etc/env.php file from a given environment
- Example: Grab the environment configuration file from integration branch feature-branch-a and place it in the local project
bin/cloud/get-env-file -e feature-branch-a
- Example: Grab the environment configuration file from integration branch feature-branch-a and place it in the local project
- Create a remote db backup of a given environment and store it locally
- Example: Create a full backup of production and store it locally within the var directory of the current project
bin/cloud/backup/backup-db -e production
- Example: Create a full backup of production and store it locally within the var directory of the current project
- Create a remote media backup of a given environment and store it locally
- Example: Create a full backup archive of the media files in staging and store them locally within the project var directory for the environment
bin/cloud/backup/backup-media -e integration
- Example: Create a full backup archive of the media files in staging and store them locally within the project var directory for the environment
- Initialize a local Magento Cloud Docker environment that's an exact replica, including database and images, of a remote Magento Cloud Commerce environment
- Example: Initialize a local docker environment based off of staging for development. Use a fresh db dump form the environment by passing the "-p" flag.
bin/docker/init-local-environment -e staging -p
- Example: Initialize a local docker environment based off of staging for development. Omit the "-p" flag in order to used the last used db dump from the environment.
bin/docker/init-local-environment -e staging
- Example: Initialize a local docker environment based off of staging for development. Use a fresh db dump form the environment by passing the "-p" flag.
- Run the deployment process on a local Magento Cloud Docker environment according to Magento Docker Deployment Modes processes
- Example: Run the developer deploy process on the currently running Magento Cloud Docker Project
bin/docker/deploy -m developer
- Example: Run the developer deploy process on the currently running Magento Cloud Docker Project
- Run validation tests on your local environment to ensure that it has the correct tools and files to successfully set up a local Magento Cloud Docker environment
bin/docker/local-environment-validation-test
- Run the composer command on the local Magento Cloud Docker environment
- Example: Run composer to install the project code's vendor directory and dependency
bin/docker/composer install
- Example: Run composer to install the project code's vendor directory and dependency
- Run the magento command on the local Magento Cloud Docker environment
- Example: Run the magento setup upgrade command on the current local docker application instance
bin/docker/magento setup:upgrade
- Example: Run the magento setup upgrade command on the current local docker application instance
- Start up the docker project containers
bin/docker/start
- Stop and removal all currently running docker containers and data
bin/docker/removeall
- Setup the local grunt configuratino for local theme development of a particular theme defined within the project.ini configuration
bin/docker/setup-grunt
- Get the Magento project code referenced within repo PRIMARY_GIT_REPO_URL and place it within the local project directory at SOURCE_DIRECTORY_NAME
bin/docker/get-core-code
- Run the grunt command for the local docker project in order to build a theme
bin/docker/grunt exec:my-theme
bin/docker/grunt less:my-theme
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU General Public License v3.0. See LICENSE.txt
for more information.
Carlos Reynosa - @carlos_reynosa
Project Link: https://github.com/carlos-reynosa/adobe-commerce-cloud-and-docker-tools