-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from sequra/refactor/PAR-480-Migrate-Magento-2…
…-Docker-image Migrate Magento 2 Docker image
- Loading branch information
Showing
36 changed files
with
1,017 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Dockerfile para PHP 7.4 con las extensiones necesarias para Magento Open Source | ||
FROM php:7.4-apache | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
mariadb-client \ | ||
libfreetype6-dev \ | ||
libjpeg62-turbo-dev \ | ||
libpng-dev \ | ||
libicu-dev \ | ||
libxslt1-dev \ | ||
libzip-dev \ | ||
libcurl4-openssl-dev \ | ||
libonig-dev \ | ||
libsodium-dev \ | ||
git \ | ||
curl \ | ||
unzip \ | ||
tar \ | ||
libpcre3 \ | ||
&& pecl install xdebug-3.1.6 redis oauth \ | ||
&& echo "extension=oauth.so" > /usr/local/etc/php/conf.d/docker-php-ext-oauth.ini \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
&& docker-php-ext-install \ | ||
bcmath \ | ||
curl \ | ||
opcache \ | ||
gd \ | ||
intl \ | ||
mbstring \ | ||
mysqli \ | ||
pdo_mysql \ | ||
simplexml \ | ||
soap \ | ||
sockets \ | ||
sodium \ | ||
tokenizer \ | ||
xmlwriter \ | ||
xsl \ | ||
zip \ | ||
&& 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 | ||
|
||
# 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.php74.sh /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 | ||
|
||
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 --mount=type=secret,id=M2_COMPOSER_REPO_KEY,env=M2_REPO_KEY \ | ||
--mount=type=secret,id=M2_COMPOSER_REPO_SECRET,env=M2_REPO_SECRET \ | ||
composer config -g --no-plugins allow-plugins true \ | ||
&& 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 ./ | ||
|
||
# Modify base entry point to run our custom setup script | ||
RUN sed -i 's/exec "$@"/\/usr\/local\/bin\/m2-entrypoint \&\& exec "$@"/g' /usr/local/bin/docker-php-entrypoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
ARG PHP_VERSION=8.2 | ||
|
||
FROM php:${PHP_VERSION}-apache | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
mariadb-client \ | ||
libfreetype6-dev \ | ||
libjpeg62-turbo-dev \ | ||
libpng-dev \ | ||
libicu-dev \ | ||
libxslt1-dev \ | ||
libzip-dev \ | ||
libssl-dev \ | ||
git \ | ||
curl \ | ||
unzip \ | ||
tar \ | ||
libpcre3 \ | ||
&& pecl install xdebug redis oauth \ | ||
&& echo "extension=oauth.so" > /usr/local/etc/php/conf.d/docker-php-ext-oauth.ini \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
&& docker-php-ext-install \ | ||
bcmath \ | ||
opcache \ | ||
gd \ | ||
intl \ | ||
mysqli \ | ||
pdo_mysql \ | ||
soap \ | ||
sockets \ | ||
xsl \ | ||
zip \ | ||
&& 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 | ||
|
||
# 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 | ||
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 | ||
|
||
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 --mount=type=secret,id=M2_COMPOSER_REPO_KEY,env=M2_REPO_KEY \ | ||
--mount=type=secret,id=M2_COMPOSER_REPO_SECRET,env=M2_REPO_SECRET \ | ||
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 ./ | ||
|
||
# Modify base entry point to run our custom setup script | ||
RUN sed -i 's/exec "$@"/\/usr\/local\/bin\/m2-entrypoint \&\& exec "$@"/g' /usr/local/bin/docker-php-entrypoint |
68 changes: 68 additions & 0 deletions
68
.docker/magento/HelperModule/Sequra/Helper/Console/Setup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 SeQura Engineering. All rights reserved. | ||
*/ | ||
|
||
namespace Sequra\Helper\Console; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Console command to trigger DR report | ||
*/ | ||
class Setup extends Command | ||
{ | ||
/** | ||
* Command name | ||
*/ | ||
const NAME = 'sequra-helper:setup'; | ||
/** | ||
* Initialize triggerreport command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName(self::NAME) | ||
->setDescription('Setup data for quick testing'); | ||
parent::configure(); | ||
} | ||
/** | ||
* Execute command. | ||
* | ||
* @param InputInterface $input InputInterface | ||
* @param OutputInterface $output OutputInterface | ||
* | ||
* @return int 0 if everything went fine, or an exit code | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | ||
$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); | ||
|
||
$customer = $customerRepository->getById(1); | ||
$customer->setLastname('Costello Costello'); | ||
$addresses = $customer->getAddresses(); | ||
if (!empty($addresses)) { | ||
$address = reset($addresses); | ||
$address->setStreet(['Nueva Calle', 'Piso 2']); | ||
$address->setCity('Barcelona'); | ||
$address->setPostcode('08010'); | ||
$address->setCountryId('ES'); | ||
$address->setTelephone('666666666'); | ||
$regionFactory = $objectManager->create(\Magento\Directory\Model\RegionFactory::class); | ||
$region = $regionFactory->create()->loadByName('Barcelona','ES'); | ||
if ($region->getId()) { | ||
$address->setRegionId($region->getId()); | ||
} | ||
} | ||
|
||
$customerRepository->save($customer); | ||
$output->writeln("Dirección actualizada correctamente"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "sequra/magento2-helper", | ||
"type": "magento2-module", | ||
"autoload": { | ||
"psr-4": { | ||
"Sequra\\Helper\\": "" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Sequra Engineering" | ||
} | ||
], | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> | ||
<group id="default"> | ||
</group> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<!-- Commandline option to triggerrerport and update orders--> | ||
<type name="Magento\Framework\Console\CommandList"> | ||
<arguments> | ||
<argument name="commands" xsi:type="array"> | ||
<item name="Setup" xsi:type="object">Sequra\Helper\Console\Setup</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Sequra_Helper" setup_version="1.0.0"> | ||
<sequence> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register( | ||
ComponentRegistrar::MODULE, | ||
'Sequra_Helper', | ||
__DIR__ | ||
); |
Oops, something went wrong.