Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker image #45

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .docker/magento/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -108,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

Expand Down
10 changes: 1 addition & 9 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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..."

Expand Down
Loading