diff --git a/.docker/magento/Dockerfile b/.docker/magento/Dockerfile index bcd8fb0..ed4ca96 100644 --- a/.docker/magento/Dockerfile +++ b/.docker/magento/Dockerfile @@ -4,7 +4,7 @@ FROM php:${PHP_VERSION}-apache SHELL ["/bin/bash", "-c"] -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends \ mariadb-client \ libfreetype6-dev \ libjpeg62-turbo-dev \ @@ -44,33 +44,46 @@ RUN apt-get update && apt-get install -y \ sockets \ xsl \ zip \ - && apt-get clean && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-enable redis xdebug + && docker-php-ext-enable \ + redis \ + xdebug \ + && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.client_host=${M2_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.log_level=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && sed -i 's/^/;/' "/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" \ + && apt-get clean && rm -rf /var/lib/apt/lists/* # Install composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer -# Enable apache modules -RUN a2enmod rewrite -RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf +# Apache configuration +RUN a2enmod rewrite && echo "ServerName localhost" >> /etc/apache2/apache2.conf +# PHP configuration COPY ./docker-php-m2.ini /usr/local/etc/php/conf.d/docker-php-m2.ini +# Custom scripts COPY ./m2-entrypoint.sh /usr/local/bin/m2-entrypoint -RUN chmod +x /usr/local/bin/m2-entrypoint +COPY ./toggle-xdebug.sh /usr/local/bin/toggle-xdebug +RUN chmod +x /usr/local/bin/m2-entrypoint && \ +chmod +x /usr/local/bin/toggle-xdebug ARG M2_VERSION ARG M2_REPO_KEY ARG M2_REPO_SECRET -RUN mkdir -p /Sequra/Core && chown -R www-data:www-data /Sequra && chmod -R 755 /Sequra +RUN mkdir -p /Sequra/Core \ + && chown -R www-data:www-data /Sequra \ + && chmod -R 755 /Sequra \ + && mkdir -p /var/www/.composer/cache/files/ \ + && chown -R www-data:www-data /var/www/.composer WORKDIR /var/www/html -RUN composer config -g http-basic.repo.magento.com $M2_REPO_KEY $M2_REPO_SECRET - -RUN composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=$M2_VERSION . \ - && composer require mageplaza/magento-2-spanish-language-pack:dev-master mageplaza/magento-2-portuguese-language-pack:dev-master mageplaza/magento-2-french-language-pack:dev-master mageplaza/magento-2-italian-language-pack:dev-master \ +RUN composer config -g http-basic.repo.magento.com $M2_REPO_KEY $M2_REPO_SECRET \ + && composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=$M2_VERSION . \ + && composer require n98/magerun2-dist mageplaza/magento-2-spanish-language-pack:dev-master mageplaza/magento-2-portuguese-language-pack:dev-master mageplaza/magento-2-french-language-pack:dev-master mageplaza/magento-2-italian-language-pack:dev-master \ && chmod -R 755 ./ \ && chown -R www-data:www-data ./ diff --git a/.docker/magento/docker-php-m2.ini b/.docker/magento/docker-php-m2.ini index 3db3955..cbedca5 100644 --- a/.docker/magento/docker-php-m2.ini +++ b/.docker/magento/docker-php-m2.ini @@ -2,10 +2,4 @@ date.timezone=Europe/Madrid memory_limit=2G realpath_cache_size=10M -realpath_cache_ttl=7200 - -# XDebug -xdebug.mode=debug -xdebug.start_with_request=yes -xdebug.client_host=localhost.sequrapi.com -xdebug.log_level=1 \ No newline at end of file +realpath_cache_ttl=7200 \ No newline at end of file diff --git a/.docker/magento/toggle-xdebug.sh b/.docker/magento/toggle-xdebug.sh new file mode 100755 index 0000000..6fac072 --- /dev/null +++ b/.docker/magento/toggle-xdebug.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# XDebug configuration file. +CONFIG_FILE="/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" + +if [[ -f "$CONFIG_FILE" ]]; then + if grep -q "^;" "$CONFIG_FILE"; then + echo "✅ Enabling XDebug" + sed -i 's/^;//' "$CONFIG_FILE" + else + echo "✅ Disabling XDebug" + sed -i 's/^/;/' "$CONFIG_FILE" + fi +else + echo "❌ The XDebug configuration file does not exist. Make sure the XDebug PHP extension is installed." + exit 1 +fi + +echo "✅ Restarting Apache" +apachectl -k graceful \ No newline at end of file diff --git a/bin/composer b/bin/composer index 69ca5a4..d1469c3 100755 --- a/bin/composer +++ b/bin/composer @@ -1,2 +1,2 @@ #!/bin/bash -docker compose exec -u daemon -w /bitnami/magento magento php vendor/bin/composer $@ \ No newline at end of file +docker compose exec -u www-data magento composer $@ \ No newline at end of file diff --git a/bin/install-sampledata b/bin/install-sampledata deleted file mode 100755 index d27d2eb..0000000 --- a/bin/install-sampledata +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -echo " Installing sample data..." -docker compose exec -w /bitnami/magento magento bash -c "rm -rf var/di/* var/generation/*" -docker compose exec -u daemon -w /bitnami/magento magento bin/magento sampledata:deploy -docker compose exec -u daemon -w /bitnami/magento magento bin/magento setup:upgrade -docker compose exec -u daemon -w /bitnami/magento magento bin/magento cache:clean -docker compose exec -u daemon -w /bitnami/magento magento bin/magento cache:flush diff --git a/bin/magento b/bin/magento index 974390a..fea1e2b 100755 --- a/bin/magento +++ b/bin/magento @@ -1,2 +1,2 @@ #!/bin/bash -docker compose exec -u daemon -w /bitnami/magento magento bin/magento $@ \ No newline at end of file +docker compose exec -u www-data magento bin/magento $@ \ No newline at end of file diff --git a/bin/mysql b/bin/mysql deleted file mode 100755 index c33b08f..0000000 --- a/bin/mysql +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -docker compose exec -u daemon -w /bitnami/magento magento bash -c \ -"mysql -h \$MAGENTO_DATABASE_HOST -P \$MAGENTO_DATABASE_PORT_NUMBER -u \$MAGENTO_DATABASE_USER \$MAGENTO_DATABASE_NAME" diff --git a/bin/n98-magerun2 b/bin/n98-magerun2 index 6319f7f..72ab32e 100755 --- a/bin/n98-magerun2 +++ b/bin/n98-magerun2 @@ -1,4 +1,2 @@ #!/bin/bash -docker compose exec -u daemon -w /bitnami/magento magento bash -c \ -"[ ! -f 'vendor/bin/n98-magerun2' ] && vendor/bin/composer require n98/magerun2-dist" -docker compose exec -u daemon -w /bitnami/magento magento vendor/bin/n98-magerun2 $@ \ No newline at end of file +docker compose exec -u www-data magento vendor/bin/n98-magerun2 $@ \ No newline at end of file diff --git a/bin/shell b/bin/shell deleted file mode 100755 index e5785a9..0000000 --- a/bin/shell +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -if [ -z "$1" ]; then - docker compose exec -u daemon -w /bitnami/magento magento bash -else - docker compose exec -u daemon -w /bitnami/magento magento bash -c "$@" -fi diff --git a/bin/update-sequra b/bin/update-sequra index 122976a..87d25c3 100755 --- a/bin/update-sequra +++ b/bin/update-sequra @@ -1,9 +1,3 @@ #!/bin/bash -echo "Mount Sequra Core module" -docker compose exec -u daemon -w /bitnami/magento magento bash -c " - php ./vendor/bin/composer config repositories.sequra/magento2-core path /Sequra/Core - COMPOSER_MIRROR_PATH_REPOS=1 php ./vendor/bin/composer reinstall sequra/magento2-core - bin/magento module:enable Sequra_Core - bin/magento setup:upgrade - /opt/bitnami/scripts/php/reload.sh -" \ No newline at end of file +echo "Updating Sequra_Core source code" +docker compose exec -u www-data magento /bin/bash -c "COMPOSER_MIRROR_PATH_REPOS=1 composer reinstall sequra/magento2-core && bin/magento module:enable Sequra_Core && bin/magento setup:upgrade" \ No newline at end of file diff --git a/bin/update-sources b/bin/update-sources deleted file mode 100755 index 681bdc6..0000000 --- a/bin/update-sources +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker cp ${COMPOSE_PROJECT_NAME:-sequra}-magento:/var/www/html .magento-src \ No newline at end of file diff --git a/bin/xdebug b/bin/xdebug index aa71b54..4091a3e 100755 --- a/bin/xdebug +++ b/bin/xdebug @@ -1,2 +1,2 @@ #!/bin/bash -docker compose exec magento /docker-entrypoint-init.d/xdebug.sh +docker compose exec magento toggle-xdebug \ No newline at end of file diff --git a/docker-entrypoint-init.d/00-set-developper-mode.sh b/docker-entrypoint-init.d/00-set-developper-mode.sh deleted file mode 100755 index 7af5482..0000000 --- a/docker-entrypoint-init.d/00-set-developper-mode.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cd /bitnami/magento/ || exit 0 -bin/magento deploy:mode:set developer \ No newline at end of file diff --git a/docker-entrypoint-init.d/01-set-order_sequence.sh b/docker-entrypoint-init.d/01-set-order_sequence.sh deleted file mode 100755 index 026b3a8..0000000 --- a/docker-entrypoint-init.d/01-set-order_sequence.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -echo \ -"ALTER TABLE sequence_order_0 AUTO_INCREMENT = $(date +%s);" \ -"ALTER TABLE sequence_order_1 AUTO_INCREMENT = $(date +%s);" | \ -mysql -h $MAGENTO_DATABASE_HOST -P $MAGENTO_DATABASE_PORT_NUMBER -u $MAGENTO_DATABASE_USER $MAGENTO_DATABASE_NAME \ No newline at end of file diff --git a/docker-entrypoint-init.d/02-additional_setting.sh b/docker-entrypoint-init.d/02-additional_setting.sh deleted file mode 100755 index 0086a37..0000000 --- a/docker-entrypoint-init.d/02-additional_setting.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cd /bitnami/magento/ || exit 0 -bin/magento config:set general/country/default $MAGENTO_COUNTRY \ No newline at end of file diff --git a/docker-entrypoint-init.d/install-sequra.sh b/docker-entrypoint-init.d/install-sequra.sh deleted file mode 100755 index e966dc4..0000000 --- a/docker-entrypoint-init.d/install-sequra.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -echo "Mount Sequra Core module" -chown -R daemon /Sequra -cd /bitnami/magento/ || exit 0 -if [ "$SQ_M2_CORE_VERSION" = "local" ]; then - php ./vendor/bin/composer config repositories.sequra/magento2-core path /Sequra/Core - COMPOSER_MIRROR_PATH_REPOS=1 php ./vendor/bin/composer require sequra/magento2-core:^2.5 -else - composer require sequra/magento2-core:"$SQ_M2_CORE_VERSION" -fi -composer require mageplaza/magento-2-spanish-language-pack:dev-master \ - mageplaza/magento-2-portuguese-language-pack:dev-master \ - mageplaza/magento-2-french-language-pack:dev-master \ - mageplaza/magento-2-italian-language-pack:dev-master; -bin/magento config:set dev/template/allow_symlink 1 -bin/magento module:enable Sequra_Core -bin/magento setup:upgrade -bin/magento sequra:configure --merchant_ref="$SQ_MERCHANT_REF" --username="$SQ_USER_NAME" --password="$SQ_USER_SECRET" --assets_key="$SQ_ASSETS_KEY" --endpoint="$SQ_ENDPOINT" - -chown -R daemon ./* diff --git a/docker-entrypoint-init.d/xdebug.sh b/docker-entrypoint-init.d/xdebug.sh deleted file mode 100755 index e6e10ec..0000000 --- a/docker-entrypoint-init.d/xdebug.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -source /opt/bitnami/scripts/apache/status.sh -if is_apache_running; then - if [ -e /opt/bitnami/php/etc/conf.d/xdebug.ini ]; then - echo "Disabling xdebug" - rm -f /opt/bitnami/php/etc/conf.d/xdebug.ini - else - echo "Enabling xdebug" - cat < /opt/bitnami/php/etc/conf.d/xdebug.ini -zend_extension = xdebug.so - -xdebug.mode = debug -xdebug.start_with_request = yes -xdebug.discover_client_host = 0 -xdebug.client_port = 9003 -xdebug.client_host=host.docker.internal -EOF - fi - /opt/bitnami/scripts/php/reload.sh -fi