Skip to content

Commit 5bd055b

Browse files
Feature: Remove Composer 1 support
1 parent 4780aee commit 5bd055b

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

magento/Dockerfile-2.3

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@ ARG SAMPLE_DATA=false
88
ENV CI=true
99
ENV URL=http://localhost/
1010
ENV FLAT_TABLES=false
11-
ENV COMPOSER_VERSION=1
1211

1312
COPY scripts/retry retry
1413
COPY scripts/install-phpstan.php scripts/install-phpstan.php
14+
COPY scripts/upgrade-to-composer-2.php scripts/upgrade-to-composer-2.php
15+
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
1516
COPY patches/vertex-compilation-issue.patch vertex-compilation-issue.patch
1617
COPY patches/APSB22-12/MDVA-43395_EE_2.4.3-p1_COMPOSER_v1.patch MDVA-43395_EE_2.4.3-p1_COMPOSER_v1.patch
1718
COPY patches/APSB22-12/MDVA-43443_EE_2.3.4_COMPOSER_v1.patch MDVA-43443_EE_2.3.4_COMPOSER_v1.patch
1819
COPY patches/APSB22-12/MDVA-43443_EE_2.4.2-p2_COMPOSER_v1.patch MDVA-43443_EE_2.4.2-p2_COMPOSER_v1.patch
1920
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini
2021

2122
RUN ./start-services && \
23+
composer self-update --2 && \
24+
echo "Composer version:" && \
25+
composer --version && \
2226
curl -o magento.zip https://repo-magento-mirror.fooman.co.nz/dist/magento/$MAGENTO_TYPE/magento-$MAGENTO_TYPE-$MAGENTO_VERSION.zip && \
2327
unzip -q magento.zip -d . && \
2428
rm magento.zip && \
29+
php scripts/allow-composer-plugins.php && \
30+
rm scripts/allow-composer-plugins.php && \
31+
php scripts/upgrade-to-composer-2.php && \
32+
rm scripts/upgrade-to-composer-2.php && \
2533
composer config --unset repositories.0 && \
2634
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/ && \
2735
./retry "composer install" && \

magento/Dockerfile-2.4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@ COPY scripts/retry retry
1414
COPY patches/ patches/
1515
COPY scripts/apply-2.4-patches.php scripts/apply-2.4-patches.php
1616
COPY scripts/downgrade-monolog.php scripts/downgrade-monolog.php
17+
COPY scripts/upgrade-to-composer-2.php scripts/upgrade-to-composer-2.php
1718
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
1819
COPY scripts/remove-paypal-braintree.php scripts/remove-paypal-braintree.php
1920
COPY scripts/patch-AC2855.php scripts/patch-AC2855.php
2021
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini
2122

2223
RUN ./start-services && \
23-
if (( $(php -r 'echo version_compare(getenv("MAGENTO_VERSION"), "2.4.2", "<=") ? "true" : "false";') = "true" )); then composer self-update --1; else composer self-update --2; fi && \
24+
composer self-update --2 && \
2425
echo "Composer version:" && \
2526
composer --version && \
2627
curl -o magento.zip https://repo-magento-mirror.fooman.co.nz/dist/magento/$MAGENTO_TYPE/magento-$MAGENTO_TYPE-$MAGENTO_VERSION.zip && \
2728
unzip -q magento.zip -d . && \
2829
rm magento.zip && \
29-
if (( $(php -r 'echo version_compare(getenv("MAGENTO_VERSION"), "2.4.2", "<=") ? "true" : "false";') = "true" )); then echo "Using Composer version 1 so skipping allow-plugins"; else php scripts/allow-composer-plugins.php rm scripts/allow-composer-plugins.php; fi && \
30+
php scripts/allow-composer-plugins.php && \
31+
rm scripts/allow-composer-plugins.php && \
32+
php scripts/upgrade-to-composer-2.php && \
33+
rm scripts/upgrade-to-composer-2.php && \
3034
composer config --unset repositories.0 && \
3135
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/ && \
3236
if [ "$MAGENTO_VERSION" = "2.4.4" ]; then composer require "magento/security-package:1.1.3-p1 as 1.1.3" --no-update; fi && \
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
$isPhp72OrLower = version_compare(PHP_VERSION, '7.2', '>=');
4+
5+
$version = getenv('MAGENTO_VERSION');
6+
$is230 = substr($version, 0, 5) == '2.3.0';
7+
$is231 = substr($version, 0, 5) == '2.3.1';
8+
$is232 = substr($version, 0, 5) == '2.3.2';
9+
$is233 = substr($version, 0, 5) == '2.3.3';
10+
$is234 = substr($version, 0, 5) == '2.3.4';
11+
$is235 = substr($version, 0, 5) == '2.3.5';
12+
$is236 = substr($version, 0, 5) == '2.3.6';
13+
$is237 = substr($version, 0, 5) == '2.3.7';
14+
$is240 = substr($version, 0, 5) == '2.4.0';
15+
$is241 = substr($version, 0, 5) == '2.4.1';
16+
$is242 = substr($version, 0, 5) == '2.4.2';
17+
$is243 = substr($version, 0, 5) == '2.4.3';
18+
$is244 = substr($version, 0, 5) == '2.4.4';
19+
$is245 = substr($version, 0, 5) == '2.4.5';
20+
$is246 = substr($version, 0, 5) == '2.4.6';
21+
$is247 = substr($version, 0, 5) == '2.4.7';
22+
23+
if ($is230 || $is231 || $is232 || $is233 || $is234) {
24+
run('composer require magento/inventory-composer-installer:"1.2.0 as 1.1.0" --no-update');
25+
return;
26+
}
27+
28+
$laminasDependencyPluginVersion = "2.1.2 as 1.0.4";
29+
if ($isPhp72OrLower) {
30+
$laminasDependencyPluginVersion = "2.0.0 as 1.0.4";
31+
}
32+
33+
if ($is234 || $is235 || $is236 || $is240 || $is241) {
34+
run('composer require laminas/laminas-dependency-plugin:"' . $laminasDependencyPluginVersion . '" --no-update');
35+
run('composer require magento/inventory-composer-installer:"1.2.0 as 1.1.0" --no-update');
36+
run('composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.7.0 --no-update');
37+
return;
38+
}
39+
40+
function run(string $command) {
41+
echo 'Running command ' . $command . PHP_EOL;
42+
43+
$output = null;
44+
$code = null;
45+
exec($command, $output, $code);
46+
47+
if ($code !== 0) {
48+
echo 'Error while running "' . $command . '"' . PHP_EOL;
49+
die($code);
50+
}
51+
}

0 commit comments

Comments
 (0)