From 508c67f44ad81233179c2c7931336d674ab048fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Hennes?= Date: Mon, 29 Jun 2026 21:03:08 +0200 Subject: [PATCH] Add _dev/ Docker environment for local testing --- _dev/.env.example | 30 ++++++++++++ _dev/.gitignore | 1 + _dev/Makefile | 106 ++++++++++++++++++++++++++++++++++++++++ _dev/docker-compose.yml | 73 +++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 _dev/.env.example create mode 100644 _dev/.gitignore create mode 100644 _dev/Makefile create mode 100644 _dev/docker-compose.yml diff --git a/_dev/.env.example b/_dev/.env.example new file mode 100644 index 0000000..0b9007b --- /dev/null +++ b/_dev/.env.example @@ -0,0 +1,30 @@ +# PrestaShop version to use (easily changeable) +PS_VERSION=9.1.1 + +# MySQL configuration +MYSQL_ROOT_PASSWORD=root +MYSQL_DATABASE=prestashop +MYSQL_USER=prestashop +MYSQL_PASSWORD=prestashop + +# Ports (can be changed if running multiple versions simultaneously) +PS_PORT=8096 +MYSQL_PORT=3313 +PMA_PORT=8097 + +# PHP version (optional, e.g. 8.3, 8.4, 8.5 — leave empty for the default bundled with the PS image) +PHP_VERSION=8.4 + +# Full image tag used by docker-compose (auto-updated by make switch, do not edit manually) +PS_IMAGE_TAG=9.1.1-8.4 + +# Docker Compose project name (used for volume isolation between versions) +COMPOSE_PROJECT_NAME=ps911php84 + +# URL of the PrestaShop instance +WEBSITE_URL=http://localhost:8096 + +# Admin credentials and path +ADMIN_EMAIL=demo@prestashop.com +ADMIN_PASSWORD=prestashop_demo +ADMIN_PATH=/admin-dev diff --git a/_dev/.gitignore b/_dev/.gitignore new file mode 100644 index 0000000..f10862a --- /dev/null +++ b/_dev/.gitignore @@ -0,0 +1 @@ +/.env diff --git a/_dev/Makefile b/_dev/Makefile new file mode 100644 index 0000000..7da26c4 --- /dev/null +++ b/_dev/Makefile @@ -0,0 +1,106 @@ +.PHONY: help up down restart logs shell install install-module fix-permissions wait setup cache-clear clean ps-install switch switch-8.1 switch-9 switch-nightly switch-9.1.1-php83 switch-9.1.1-php84 switch-9.1.1-php85 + +SHELL := /bin/bash + +# Load .env file +include .env +export + +# Project name: PS version + PHP version (if set) for full isolation +COMPOSE_PROJECT := ps$(subst .,,$(PS_VERSION))$(if $(PHP_VERSION),php$(subst .,,$(PHP_VERSION)),) + +# Full image tag: PS_VERSION with optional -PHP_VERSION suffix +PS_IMAGE_TAG := $(PS_VERSION)$(if $(PHP_VERSION),-$(PHP_VERSION),) + +help: ## Display help + @grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + +up: ## Start the PrestaShop environment + @echo "Starting PrestaShop $(PS_IMAGE_TAG)..." + docker compose -p $(COMPOSE_PROJECT) up -d + @echo "PrestaShop $(PS_IMAGE_TAG) available at http://localhost:${PS_PORT}" + @echo "phpMyAdmin available at http://localhost:${PMA_PORT}" + +down: ## Stop the environment + @echo "Stopping PrestaShop $(PS_IMAGE_TAG)..." + docker compose -p $(COMPOSE_PROJECT) down + +restart: down up ## Restart the environment + +logs: ## Show logs + docker compose -p $(COMPOSE_PROJECT) logs -f prestashop + +shell: ## Access the PrestaShop container shell + docker compose -p $(COMPOSE_PROJECT) exec prestashop bash + +install: ## Install composer dependencies + composer install + +fix-permissions: ## Fix cache/log directory permissions (run if you get storage directory errors) + docker compose -p $(COMPOSE_PROJECT) exec prestashop chown -R www-data:www-data /var/www/html/var + +install-module: ## Install the module in PrestaShop + docker compose -p $(COMPOSE_PROJECT) exec prestashop bin/console prestashop:module install eicaptcha + +wait: ## Wait for PrestaShop to be fully installed and ready + @echo "Waiting for PrestaShop to be ready (this can take a few minutes)..." + @until docker compose -p $(COMPOSE_PROJECT) exec -T prestashop curl -sf http://localhost/index.php -o /dev/null; do \ + echo " Not ready yet, retrying in 15s..."; \ + sleep 15; \ + done + @echo "PrestaShop is ready!" + +cache-clear: ## Clear PrestaShop cache + docker compose -p $(COMPOSE_PROJECT) exec prestashop bin/console cache:clear + +setup: wait install-module cache-clear ## Full setup: wait for PS to be ready, install module, clear cache + @echo "" + @echo "Setup complete! eicaptcha is installed and active." + +clean: ## Completely remove the environment (deletes data) + @echo "Removing PrestaShop $(PS_IMAGE_TAG) and its data..." + docker compose -p $(COMPOSE_PROJECT) down -v + +ps-install: up ## Start installation and open browser + @echo "Installing PrestaShop $(PS_IMAGE_TAG)" + @echo "Access http://localhost:${PS_PORT}" + @sleep 5 + @command -v open >/dev/null && open http://localhost:${PS_PORT} || echo "Open http://localhost:${PS_PORT} in your browser" + +switch-8.1: ## Switch to PrestaShop 8.1 + @$(MAKE) switch PS_VERSION=8.1 PHP_VERSION= PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch-9: ## Switch to PrestaShop 9 + @$(MAKE) switch PS_VERSION=9 PHP_VERSION= PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch-nightly: ## Switch to PrestaShop nightly + @$(MAKE) switch PS_VERSION=nightly PHP_VERSION= PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch-9.1.1-php83: ## Switch to PrestaShop 9.1.1 with PHP 8.3 + @$(MAKE) switch PS_VERSION=9.1.1 PHP_VERSION=8.3 PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch-9.1.1-php84: ## Switch to PrestaShop 9.1.1 with PHP 8.4 + @$(MAKE) switch PS_VERSION=9.1.1 PHP_VERSION=8.4 PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch-9.1.1-php85: ## Switch to PrestaShop 9.1.1 with PHP 8.5 + @$(MAKE) switch PS_VERSION=9.1.1 PHP_VERSION=8.5 PS_PORT=8096 MYSQL_PORT=3313 PMA_PORT=8097 + +switch: ## Change PrestaShop version (internal use) + @sed -i \ + -e "s/^PS_VERSION=.*/PS_VERSION=${PS_VERSION}/" \ + -e "s/^PS_PORT=.*/PS_PORT=${PS_PORT}/" \ + -e "s/^MYSQL_PORT=.*/MYSQL_PORT=${MYSQL_PORT}/" \ + -e "s/^PMA_PORT=.*/PMA_PORT=${PMA_PORT}/" \ + .env + @grep -q '^PHP_VERSION=' .env && \ + sed -i "s/^PHP_VERSION=.*/PHP_VERSION=$(PHP_VERSION)/" .env || \ + echo "PHP_VERSION=$(PHP_VERSION)" >> .env + @grep -q '^PS_IMAGE_TAG=' .env && \ + sed -i "s/^PS_IMAGE_TAG=.*/PS_IMAGE_TAG=$(PS_IMAGE_TAG)/" .env || \ + echo "PS_IMAGE_TAG=$(PS_IMAGE_TAG)" >> .env + @grep -q '^COMPOSE_PROJECT_NAME=' .env && \ + sed -i "s/^COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT)/" .env || \ + echo "COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT)" >> .env + @echo "Switched to PrestaShop $(PS_IMAGE_TAG)" + @echo "Ports: PrestaShop=${PS_PORT}, MySQL=${MYSQL_PORT}, phpMyAdmin=${PMA_PORT}" + @echo "Run 'make up' to start" diff --git a/_dev/docker-compose.yml b/_dev/docker-compose.yml new file mode 100644 index 0000000..19c4905 --- /dev/null +++ b/_dev/docker-compose.yml @@ -0,0 +1,73 @@ +name: ${COMPOSE_PROJECT_NAME:-ps911} + +services: + + prestashop: + image: prestashop/prestashop:${PS_IMAGE_TAG:-9.1.1} + container_name: ps_${PS_VERSION}_eicaptcha + ports: + - "${PS_PORT:-8096}:80" + environment: + - DB_SERVER=mysql + - DB_NAME=${MYSQL_DATABASE} + - DB_USER=${MYSQL_USER} + - DB_PASSWD=${MYSQL_PASSWORD} + - PS_INSTALL_AUTO=1 + - PS_DOMAIN=localhost:${PS_PORT:-8096} + - PS_DEV_MODE=1 + - PS_ENABLE_SSL=0 + - XDEBUG_MODE=debug + - XDEBUG_CONFIG=client_host=host.docker.internal client_port=9003 + volumes: + - ../:/var/www/html/modules/eicaptcha + - ps-data:/var/www/html + depends_on: + mysql: + condition: service_healthy + extra_hosts: + - "host.docker.internal:host-gateway" + networks: + - prestashop-network + + mysql: + image: mysql:8.0 + container_name: ps_mysql_${PS_VERSION}_eicaptcha + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + volumes: + - mysql-data:/var/lib/mysql + ports: + - "${MYSQL_PORT:-3313}:3306" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s + networks: + - prestashop-network + + phpmyadmin: + image: phpmyadmin/phpmyadmin + container_name: ps_phpmyadmin_${PS_VERSION}_eicaptcha + environment: + - PMA_HOST=mysql + - PMA_USER=${MYSQL_USER} + - PMA_PASSWORD=${MYSQL_PASSWORD} + ports: + - "${PMA_PORT:-8097}:80" + depends_on: + - mysql + networks: + - prestashop-network + +volumes: + ps-data: + mysql-data: + +networks: + prestashop-network: + driver: bridge