From 0ec9cdcdc380a1fd718e696f64ae1e4c423fe7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Escalante=20=C3=81lvarez?= Date: Fri, 14 Feb 2025 17:29:06 +0100 Subject: [PATCH 1/3] Update Magento version support in build script and .env.sample to include 2.4.7-p4 --- .docker/magento/build-image.sh | 11 ++++++++--- .env.sample | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.docker/magento/build-image.sh b/.docker/magento/build-image.sh index c24e29b..ce87c7a 100755 --- a/.docker/magento/build-image.sh +++ b/.docker/magento/build-image.sh @@ -28,7 +28,7 @@ fi # Parse arguments: # --push: Push the image to the registry -# --magento=VERSION: Supported versions are 2.4.3-p3, 2.4.4-p11, 2.4.5-p10, 2.4.6-p8, 2.4.7-p3 +# --magento=VERSION: Supported versions are 2.4.3-p3, 2.4.4-p11, 2.4.5-p10, 2.4.6-p8, 2.4.7-p3, 2.4.7-p4 # --php=VERSION: Supported versions are 7.4, 8.1, 8.2 while [[ "$#" -gt 0 ]]; do if [ "$1" == "--push" ]; then @@ -60,8 +60,8 @@ if [ "$PHP_VERSION" != "7.4" ] && [ "$PHP_VERSION" != "8.1" ] && [ "$PHP_VERSION fi # Check if the Magento version is supported -if [ "$M2_VERSION" != "2.4.3-p3" ] && [ "$M2_VERSION" != "2.4.4-p11" ] && [ "$M2_VERSION" != "2.4.5-p10" ] && [ "$M2_VERSION" != "2.4.6-p8" ] && [ "$M2_VERSION" != "2.4.7-p3" ]; then - echo "❌ Magento version $M2_VERSION is not supported. Supported versions are 2.4.3-p3, 2.4.4-p11, 2.4.5-p10, 2.4.6-p8, 2.4.7-p3" +if [ "$M2_VERSION" != "2.4.3-p3" ] && [ "$M2_VERSION" != "2.4.4-p11" ] && [ "$M2_VERSION" != "2.4.5-p10" ] && [ "$M2_VERSION" != "2.4.6-p8" ] && [ "$M2_VERSION" != "2.4.7-p3" ] && [ "$M2_VERSION" != "2.4.7-p4" ]; then + echo "❌ Magento version $M2_VERSION is not supported. Supported versions are 2.4.3-p3, 2.4.4-p11, 2.4.5-p10, 2.4.6-p8, 2.4.7-p3, 2.4.7-p4" exit 1 fi @@ -91,6 +91,11 @@ if [ "$M2_VERSION" == "2.4.7-p3" ] && [ "$PHP_VERSION" != "8.2" ]; then exit 1 fi +if [ "$M2_VERSION" == "2.4.7-p4" ] && [ "$PHP_VERSION" != "8.2" ]; then + echo "❌ Magento version $M2_VERSION is not compatible with PHP version $PHP_VERSION. Please use PHP version 8.2" + exit 1 +fi + build_args="--secret id=M2_COMPOSER_REPO_KEY --secret id=M2_COMPOSER_REPO_SECRET" build_args+=" --build-arg PHP_VERSION=$PHP_VERSION" build_args+=" --build-arg M2_VERSION=$M2_VERSION" diff --git a/.env.sample b/.env.sample index 881c69d..4dd0153 100644 --- a/.env.sample +++ b/.env.sample @@ -39,7 +39,8 @@ PHP_VERSION=8.2 # Compatible with Magento 2.4.7, 2.4.6 # M2_VERSION=2.4.4-p11 # M2_VERSION=2.4.5-p10 # M2_VERSION=2.4.6-p8 -M2_VERSION=2.4.7-p3 +# M2_VERSION=2.4.7-p3 +M2_VERSION=2.4.7-p4 # The hostname of the database server M2_DB_HOST=mariadb From 2d2053326bfb7a2bdf0bda437637d5e9e8b90363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Escalante=20=C3=81lvarez?= Date: Fri, 14 Feb 2025 17:29:45 +0100 Subject: [PATCH 2/3] Simplify setup script by removing the build option and always running docker compose up --- README.md | 1 - setup.sh | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index c1c2d81..64e9b28 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ Additionally, the setup script supports the following arguments: | -------- | ------------------------------------------------------------------ | | `--ngrok` | Starts an ngrok container to expose the site to internet using HTTPS. An ngrok Auth Token must be provided either as an argument or as a variable in the `.env` file for it to work | | `--ngrok-token=YOUR_NGROK_TOKEN` | Define the ngrok Auth Token | -| `--build` | Force building Docker images | | `--open-browser` | Open the browser and navigate to the Magento root URL once the installation is complete | ### Customization diff --git a/setup.sh b/setup.sh index 244534f..b607d39 100755 --- a/setup.sh +++ b/setup.sh @@ -11,19 +11,15 @@ if [ ! -f .env ]; then fi ngrok=0 -build=0 open_browser=0 # Parse arguments: -# --build: Build of docker images # --ngrok-token=YOUR_NGROK_TOKEN: Override the ngrok token in .env # --ngrok: Use ngrok to expose the site # --open-browser: Open the browser after the installation is complete while [[ "$#" -gt 0 ]]; do if [ "$1" == "--ngrok" ]; then ngrok=1 - elif [ "$1" == "--build" ]; then - build=1 elif [[ "$1" == --ngrok-token=* ]]; then ngrok_token="${1#*=}" sed -i.bak "s|NGROK_AUTHTOKEN=.*|NGROK_AUTHTOKEN=$ngrok_token|" .env @@ -89,11 +85,7 @@ if [ $ngrok -eq 1 ]; then echo "✅ Ngrok started. Public URL: $M2_URL" fi -if [ $build -eq 1 ]; then - docker compose up -d --build || exit 1 -else - docker compose up -d || exit 1 -fi +docker compose up -d || exit 1 echo "🚀 Waiting for installation to complete..." From ca1d0fe989307c2a4fcbe19cc84b11eae2ec7442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Escalante=20=C3=81lvarez?= Date: Fri, 14 Feb 2025 17:48:21 +0100 Subject: [PATCH 3/3] Add XDebug debugging instructions for VS Code to README --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 64e9b28..08bb9ee 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,40 @@ This repo contains a group of utility scripts under `bin/` directory. The goal i | `bin/update-sequra` | Reinstall the seQura plugin in Magento's `vendor` directory using the project files as the repository. | | `bin/xdebug` | Toggle XDebug on/off. By default XDebug comes disabled by default. | +## Debugging with XDebug + +Create a VS Code Workspace file at `.vscode/magento2-core.code-workspace` with the following content: + +```json +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003, + "pathMappings": { + "/var/www/html/vendor/sequra/magento2-core": "${workspaceFolder}", + "/var/www/html/app/code/Sequra/Helper": "${workspaceFolder}/.docker/magento/HelperModule/Sequra/Helper" + } + } + ] + } + } +} +``` +Then start debugging (F5) making sure you have the option `Listen for Xdebug (workspace)` selected in VS Code + +> [!NOTE] +> You need to install and activate [PHP Debug](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) extension ## Building Docker images