Skip to content
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
20 changes: 20 additions & 0 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MAGENTO_PUBLIC_KEY=
MAGENTO_PRIVATE_KEY=
MAGENTO_VERSION=2.4.*
MAGENTO_BASE_URL=http://localhost:8080/

MAGENTO_DB_HOST=db
MAGENTO_DB_NAME=magento
MAGENTO_DB_USER=magento
MAGENTO_DB_PASSWORD=magento

MAGENTO_SEARCH_ENGINE=opensearch
MAGENTO_OPENSEARCH_HOST=opensearch
MAGENTO_OPENSEARCH_PORT=9200

MAGENTO_ADMIN_FIRSTNAME=Admin
MAGENTO_ADMIN_LASTNAME=User
MAGENTO_ADMIN_EMAIL=admin@example.com
MAGENTO_ADMIN_USER=admin
MAGENTO_ADMIN_PASSWORD=Admin123!Admin123!
MAGENTO_ADMIN_URI=admin
93 changes: 93 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
FROM php:8.2-fpm-bullseye

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
git \
curl \
procps \
rsync \
unzip \
zip \
ca-certificates \
default-mysql-client \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
libicu-dev \
libxml2-dev \
libxslt1-dev \
libonig-dev \
libcurl4-openssl-dev \
libssl-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j"$(nproc)" \
bcmath \
curl \
ftp \
gd \
intl \
mbstring \
mysqli \
pdo_mysql \
soap \
sockets \
xsl \
zip \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& rm -rf /var/lib/apt/lists/*

ENV NVM_DIR=/usr/local/nvm
ENV NODE_VERSION=20

RUN mkdir -p "$NVM_DIR" \
&& curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install "$NODE_VERSION" \
&& nvm alias default "$NODE_VERSION" \
&& nvm use default

ENV NODE_PATH="$NVM_DIR/versions/node/v${NODE_VERSION}/lib/node_modules"
ENV PATH="$NVM_DIR/versions/node/v${NODE_VERSION}/bin:${PATH}"

COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

ENV COMPOSER_HOME=/composer
ENV PATH="/composer/vendor/bin:${PATH}"

RUN mkdir -p /composer \
&& git config --global --add safe.directory /var/www/magento/app/code/ImageKit/ImageKitMagento \
&& composer --version \
&& composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true \
&& composer global require --no-interaction --prefer-dist \
squizlabs/php_codesniffer:^3.9 \
phpcompatibility/php-compatibility:^9.3 \
magento/magento-coding-standard:^35 \
phpstan/phpstan:^1.12 \
phpunit/phpunit:^10.5 \
&& phpcs --config-set installed_paths "/composer/vendor/magento/magento-coding-standard,/composer/vendor/phpcompatibility/php-compatibility"

ARG MAGENTO_PUBLIC_KEY
ARG MAGENTO_PRIVATE_KEY
ARG MAGENTO_VERSION=2.4.*

RUN composer config --global --auth http-basic.repo.magento.com "${MAGENTO_PUBLIC_KEY}" "${MAGENTO_PRIVATE_KEY}" \
&& COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ \
magento/project-community-edition="${MAGENTO_VERSION}" /var/www/magento \
&& rm -f /composer/auth.json

RUN { \
echo "xdebug.mode=develop,debug"; \
echo "xdebug.start_with_request=yes"; \
echo "xdebug.discover_client_host=0"; \
echo "xdebug.client_host=host.docker.internal"; \
echo "xdebug.client_port=9003"; \
} > /usr/local/etc/php/conf.d/99-xdebug.ini \
&& echo "memory_limit = -1" > /usr/local/etc/php/conf.d/99-memory.ini

WORKDIR /var/www/magento/app/code/ImageKit/ImageKitMagento

CMD ["php-fpm", "-F"]
69 changes: 69 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Dev Container (Magento Latest 2.4 E2E)

This dev container provides an end-to-end Magento 2.4 environment for this module.

## What is included

- PHP 8.2 + PHP-FPM
- Nginx
- MariaDB 10.6
- OpenSearch 2.x
- Xdebug
- Composer
- PHP_CodeSniffer + Magento Coding Standard
- PHPStan
- PHPUnit

## Prerequisites

To download Magento source on first bootstrap, export your Adobe Commerce Marketplace keys:

```bash
export MAGENTO_PUBLIC_KEY="<your-public-key>"
export MAGENTO_PRIVATE_KEY="<your-private-key>"
```

You can also create `.devcontainer/.env` from `.devcontainer/.env.example` and keep credentials there.

## First-time setup

1. Open this repository in VS Code.
2. Run **Dev Containers: Reopen in Container**.
3. In the container terminal, run:

```bash
.devcontainer/scripts/bootstrap-magento.sh
```

When done:

- Storefront: `http://localhost:8080/`
- Admin: `http://localhost:8080/admin`
- Default admin: `admin / Admin123!Admin123!`
- OpenSearch API: `http://localhost:9200/`

## Daily workflow

After editing this module, sync it into Magento and run upgrade:

```bash
.devcontainer/scripts/install-module.sh
```

## Useful commands

Run from inside `/var/www/magento`:

```bash
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:di:compile
```

Run static analysis tools from the container:

```bash
phpcs --severity=9 --standard=Magento2 --ignore=*/vendor/* .
phpstan --version
phpunit --version
```
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "ImageKit Magento Latest E2E",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/var/www/magento/app/code/ImageKit/ImageKitMagento",
"shutdownAction": "stopCompose",
"forwardPorts": [
8080,
3306,
9200
],
"portsAttributes": {
"8080": {
"label": "Magento",
"onAutoForward": "notify"
},
"3306": {
"label": "MariaDB",
"onAutoForward": "silent"
},
"9200": {
"label": "OpenSearch",
"onAutoForward": "silent"
}
},
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug",
"ms-azuretools.vscode-docker"
],
"settings": {
"php.validate.executablePath": "/usr/local/bin/php",
"editor.formatOnSave": false,
"intelephense.environment.phpVersion": "8.2.0"
}
}
},
"containerEnv": {
"MAGENTO_ROOT": "/var/www/magento"
},
"postCreateCommand": "bash .devcontainer/scripts/post-create.sh"
}
80 changes: 80 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
MAGENTO_PUBLIC_KEY: ${MAGENTO_PUBLIC_KEY:-}
MAGENTO_PRIVATE_KEY: ${MAGENTO_PRIVATE_KEY:-}
MAGENTO_VERSION: ${MAGENTO_VERSION:-2.4.*}
environment:
MAGENTO_ROOT: /var/www/magento
PHP_IDE_CONFIG: serverName=imagekit-magento
XDEBUG_MODE: debug,develop
XDEBUG_CONFIG: client_host=host.docker.internal client_port=9003 idekey=VSCODE
MAGENTO_PUBLIC_KEY: ${MAGENTO_PUBLIC_KEY:-}
MAGENTO_PRIVATE_KEY: ${MAGENTO_PRIVATE_KEY:-}
MAGENTO_VERSION: ${MAGENTO_VERSION:-2.4.*}
MAGENTO_BASE_URL: ${MAGENTO_BASE_URL:-http://localhost:8080/}
MAGENTO_DB_HOST: ${MAGENTO_DB_HOST:-db}
MAGENTO_DB_NAME: ${MAGENTO_DB_NAME:-magento}
MAGENTO_DB_USER: ${MAGENTO_DB_USER:-magento}
MAGENTO_DB_PASSWORD: ${MAGENTO_DB_PASSWORD:-magento}
MAGENTO_SEARCH_ENGINE: ${MAGENTO_SEARCH_ENGINE:-opensearch}
MAGENTO_OPENSEARCH_HOST: ${MAGENTO_OPENSEARCH_HOST:-opensearch}
MAGENTO_OPENSEARCH_PORT: ${MAGENTO_OPENSEARCH_PORT:-9200}
MAGENTO_ADMIN_FIRSTNAME: ${MAGENTO_ADMIN_FIRSTNAME:-Admin}
MAGENTO_ADMIN_LASTNAME: ${MAGENTO_ADMIN_LASTNAME:-User}
MAGENTO_ADMIN_EMAIL: ${MAGENTO_ADMIN_EMAIL:-admin@example.com}
MAGENTO_ADMIN_USER: ${MAGENTO_ADMIN_USER:-admin}
MAGENTO_ADMIN_PASSWORD: ${MAGENTO_ADMIN_PASSWORD:-Admin123!Admin123!}
MAGENTO_ADMIN_URI: ${MAGENTO_ADMIN_URI:-admin}
volumes:
- magento-data:/var/www/magento
- ..:/var/www/magento/app/code/ImageKit/ImageKitMagento
depends_on:
- db
- opensearch

web:
image: nginx:1.26-alpine
depends_on:
- app
ports:
- "8080:80"
volumes:
- magento-data:/var/www/magento
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro

db:
image: mariadb:10.6
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: magento
MYSQL_USER: magento
MYSQL_PASSWORD: magento
ports:
- "3306:3306"
volumes:
- mariadb-data:/var/lib/mysql

opensearch:
image: opensearchproject/opensearch:2.19.1
environment:
discovery.type: single-node
DISABLE_INSTALL_DEMO_CONFIG: "true"
DISABLE_SECURITY_PLUGIN: "true"
OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m"
ports:
- "9200:9200"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- opensearch-data:/usr/share/opensearch/data

volumes:
magento-data:
mariadb-data:
opensearch-data:
Loading