Skip to content

Commit eada9f8

Browse files
WIP
1 parent c61fd53 commit eada9f8

19 files changed

+420
-26
lines changed

mage-os/Dockerfile

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG PHP_VERSION=php74-fpm
22
FROM michielgerritsen/magento2-base-image:${PHP_VERSION}
33

4-
ARG MAGEOS_VERSION=2.4.4
4+
ARG MAGEOS_VERSION=1.0.0
55
ARG MAGEOS_TYPE=project-community-edition
66
ARG SAMPLE_DATA=false
77

@@ -11,13 +11,7 @@ ENV FLAT_TABLES=false
1111
ENV COMPOSER_ALLOW_SUPERUSER=1
1212

1313
COPY scripts/retry retry
14-
COPY patches/ patches/
15-
COPY scripts/apply-2.4-patches.php scripts/apply-2.4-patches.php
16-
COPY scripts/downgrade-monolog.php scripts/downgrade-monolog.php
17-
COPY scripts/upgrade-to-composer-2.php scripts/upgrade-to-composer-2.php
1814
COPY scripts/allow-composer-plugins.php scripts/allow-composer-plugins.php
19-
COPY scripts/remove-paypal-braintree.php scripts/remove-paypal-braintree.php
20-
COPY scripts/patch-AC2855.php scripts/patch-AC2855.php
2115
COPY templates/memory-limit-php.ini /usr/local/etc/php/conf.d/memory-limit-php.ini
2216

2317
RUN set -e; \
@@ -26,21 +20,14 @@ RUN set -e; \
2620
echo "[cad] Composer version:" && \
2721
composer --version && \
2822
echo "[cad] Downloading & unzipping Magento" && \
29-
curl -o mage-os.zip https://repo.mage-os.org/dist/magento/$MAGEOS_TYPE/magento-$MAGEOS_TYPE-$MAGEOS_VERSION.zip && \
30-
unzip -q mage-os.zip -d . && \
31-
rm mage-os.zip; \
23+
composer create-project --repository-url=https://repo.mage-os.org/ mage-os/project-community-edition:"$MAGEOS_VERSION" .
3224
echo "[cad] Allowing composer plugins" && \
3325
php scripts/allow-composer-plugins.php && \
3426
rm scripts/allow-composer-plugins.php && \
35-
echo "[cad] Upgrading to composer 2" && \
36-
php scripts/upgrade-to-composer-2.php && \
37-
rm scripts/upgrade-to-composer-2.php && \
38-
if [ "$MAGEOS_VERSION" != "2.4.9-alpha2" ]; then \
27+
if [ "$MAGEOS_VERSION" != "alpha2" ]; then \
3928
composer config --unset repositories.0 && \
4029
composer config repositories.fooman composer https://repo-magento-mirror.fooman.co.nz/; \
4130
fi && \
42-
if [ "$MAGEOS_VERSION" = "2.4.4" ]; then composer require "magento/security-package:1.1.3-p1 as 1.1.3" --no-update; fi && \
43-
if [ "$MAGEOS_VERSION" = "2.4.4" ]; then composer require "magento/inventory-metapackage:1.2.4-p1 as 1.2.4" --no-update; fi && \
4431
echo "[cad] Running Composer install" && \
4532
./retry "composer install" && \
4633
php scripts/patch-AC2855.php && \
@@ -55,8 +42,8 @@ RUN set -e; \
5542
php bin/magento setup:install --backend-frontname=admin --session-save=db --db-host=127.0.0.1 --db-name=magento --db-user=magento --db-password=password --base-url=http://localhost --timezone=Europe/Amsterdam --currency=EUR --admin-user=exampleuser --admin-password=examplepassword123 --admin-email=user@example.com --admin-firstname=Example --admin-lastname=Example --use-rewrites=1 --use-sample-data && \
5643
echo "[cad] Setting developer mode" && \
5744
php bin/magento deploy:mode:set developer && \
58-
if [ "${SAMPLE_DATA}" = "true" ] && [ "$MAGEOS_VERSION" != "2.4.9-alpha2" ]; then echo "[cad] Running php bin/magento sampledata:deploy"; php bin/magento sampledata:deploy; fi && \
59-
if [ "${SAMPLE_DATA}" = "true" ] && [ "$MAGEOS_VERSION" = "2.4.9-alpha2" ]; then echo "[cad] Installing sampledata"; composer require mage-os/module-bundle-sample-data mage-os/module-catalog-sample-data mage-os/module-sales-sample-data mage-os/module-customer-sample-data mage-os/module-cms-sample-data mage-os/module-widget-sample-data mage-os/module-theme-sample-data mage-os/module-downloadable-sample-data mage-os/module-wishlist-sample-data mage-os/module-review-sample-data mage-os/module-tax-sample-data mage-os/module-catalog-rule-sample-data mage-os/module-configurable-sample-data mage-os/module-product-links-sample-data mage-os/module-sales-rule-sample-data mage-os/module-msrp-sample-data mage-os/module-grouped-product-sample-data mage-os/module-swatches-sample-data mage-os/module-offline-shipping-sample-data magento/sample-data-media --ignore-platform-reqs; fi && \
45+
if [ "${SAMPLE_DATA}" = "true" ] && [ "$MAGEOS_VERSION" != "alpha2" ]; then echo "[cad] Running php bin/magento sampledata:deploy"; php bin/magento sampledata:deploy; fi && \
46+
if [ "${SAMPLE_DATA}" = "true" ] && [ "$MAGEOS_VERSION" = "alpha2" ]; then echo "[cad] Installing sampledata"; composer require mage-os/module-bundle-sample-data mage-os/module-catalog-sample-data mage-os/module-sales-sample-data mage-os/module-customer-sample-data mage-os/module-cms-sample-data mage-os/module-widget-sample-data mage-os/module-theme-sample-data mage-os/module-downloadable-sample-data mage-os/module-wishlist-sample-data mage-os/module-review-sample-data mage-os/module-tax-sample-data mage-os/module-catalog-rule-sample-data mage-os/module-configurable-sample-data mage-os/module-product-links-sample-data mage-os/module-sales-rule-sample-data mage-os/module-msrp-sample-data mage-os/module-grouped-product-sample-data mage-os/module-swatches-sample-data mage-os/module-offline-shipping-sample-data magento/sample-data-media --ignore-platform-reqs; fi && \
6047
if [ "${SAMPLE_DATA}" = "true" ]; then echo "[cad] Running setup:upgrade" && ./retry "php bin/magento setup:upgrade"; fi && \
6148
php bin/magento setup:static-content:deploy en_US -f -j 12 && \
6249
php bin/magento setup:di:compile && \
@@ -74,16 +61,15 @@ COPY templates/install-config-mysql.php dev/tests/integration/etc/
7461
COPY templates/post-install-setup-command-config.php dev/tests/integration/etc/
7562
COPY entrypoint.sh entrypoint.sh
7663

77-
COPY scripts/enable-flat-catalog enable-flat-catalog
7864
COPY scripts/change-base-url change-base-url
7965
COPY scripts/install-composer-package install-composer-package
8066
COPY scripts/disable-2fa disable-2fa
8167

82-
COPY templates/phpunit-integration.xml dev/tests/integration/phpunit.xml
83-
COPY templates/phpunit-integration-248.xml dev/tests/integration/phpunit-248.xml
84-
COPY templates/phpunit-unit.xml dev/tests/unit/phpunit.xml
85-
COPY templates/phpunit-unit-248.xml dev/tests/unit/phpunit-248.xml
86-
COPY scripts/fix-phpunit.xml.php fix-phpunit.xml.php
68+
#COPY templates/phpunit-integration.xml dev/tests/integration/phpunit.xml
69+
#COPY templates/phpunit-integration-248.xml dev/tests/integration/phpunit-248.xml
70+
#COPY templates/phpunit-unit.xml dev/tests/unit/phpunit.xml
71+
#COPY templates/phpunit-unit-248.xml dev/tests/unit/phpunit-248.xml
72+
#COPY scripts/fix-phpunit.xml.php fix-phpunit.xml.php
8773

8874
RUN chmod +x enable-flat-catalog && \
8975
chmod +x change-base-url && \

mage-os/entrypoint.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Comes from the parent image
4+
./start-services
5+
6+
if [ -n "$URL" ] && [ "$URL" != "http://localhost/" ]; then
7+
echo "Updating Base URL"
8+
magerun2 config:store:set web/unsecure/base_url $URL
9+
magerun2 config:store:set web/secure/base_url $URL
10+
magerun2 config:store:set web/unsecure/base_link_url $URL
11+
magerun2 config:store:set web/secure/base_link_url $URL
12+
magerun2 cache:flush
13+
fi
14+
15+
# Allow to set the commands in an environment variable
16+
if [[ ! -z "${CUSTOM_ENTRYPOINT_COMMAND}" ]]; then
17+
echo "${CUSTOM_ENTRYPOINT_COMMAND}" > custom-entrypoint.sh
18+
fi
19+
20+
if [ -f custom-entrypoint.sh ]; then
21+
bash ./custom-entrypoint.sh
22+
fi
23+
24+
if [ "$FLAT_TABLES" = "true" ]; then
25+
echo "Enabling Flat Tables"
26+
magerun2 config:store:set catalog/frontend/flat_catalog_category 1
27+
magerun2 config:store:set catalog/frontend/flat_catalog_product 1
28+
php bin/magento cache:flush
29+
php bin/magento indexer:reindex
30+
fi
31+
32+
if [ "$DISABLE_2FA" = "true" ] && grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
33+
echo "Disabling Two Factor Authentication"
34+
php bin/magento module:disable Magento_TwoFactorAuth -f
35+
fi
36+
37+
while sleep 5; do
38+
ps aux |grep elasticsearch |grep -q -v grep
39+
ELASTICSEARCH_STATUS=$?
40+
ps aux |grep mysqld_safe |grep -q -v grep
41+
MYSQL_STATUS=$?
42+
ps aux |grep php |grep -q -v grep
43+
PHP_STATUS=$?
44+
45+
if [ $ELASTICSEARCH_STATUS -ne 0 -o $MYSQL_STATUS -ne 0 -o $PHP_STATUS -ne 0 ]; then
46+
echo "One of the processes has already exited."
47+
exit 1
48+
fi
49+
done
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$composerPlugins = [
4+
'captainhook/plugin-composer',
5+
'dealerdirect/phpcodesniffer-composer-installer',
6+
'laminas/laminas-dependency-plugin',
7+
'phpstan/extension-installer',
8+
'magento/*',
9+
];
10+
11+
foreach ($composerPlugins as $pluginName) {
12+
echo 'Allowing ' . $pluginName . PHP_EOL;
13+
exec('composer config --no-plugins allow-plugins.' . $pluginName . ' true');
14+
}

mage-os/scripts/change-base-url

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$#" -ne 1 ] || [ "$1" == "-h" ]; then
6+
echo 'Usage: `change-base-url <domain>`.';
7+
echo 'Example: `change-base-url https://my-custom-url.test/`';
8+
echo 'Please make sure to include the training slash.';
9+
exit;
10+
fi
11+
12+
URL=$1
13+
magerun2 config:store:set web/unsecure/base_url $URL &
14+
magerun2 config:store:set web/secure/base_url $URL &
15+
magerun2 config:store:set web/unsecure/base_link_url $URL &
16+
magerun2 config:store:set web/secure/base_link_url $URL &
17+
18+
wait
19+
20+
bin/magento cache:flush config

mage-os/scripts/disable-2fa

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
4+
./retry "php bin/magento module:disable Magento_TwoFactorAuth -f"
5+
else
6+
echo "Magento_TwoFactorAuth is not installed"
7+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -eq 0 ]; then
4+
echo "Please provide at least one argument."
5+
exit 1
6+
fi
7+
8+
packages=""
9+
for package in "$@"
10+
do
11+
packages="$packages $package"
12+
done
13+
14+
composer require $packages --no-plugins --no-interaction
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
//$version = getenv('MAGENTO_VERSION');
5+
6+
$output = null;
7+
$code = null;
8+
exec('composer require --dev phpstan/phpstan:~1.0 bitexpert/phpstan-magento phpstan/extension-installer', $output, $code);
9+
10+
if ($code !== 0) {
11+
echo 'Unable to install PHPStan' . PHP_EOL;
12+
die($code);
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Installing sampledata. This can take a while"
6+
php bin/magento sampledata:deploy
7+
php bin/magento setup:upgrade
8+
php bin/magento setup:di:compile

mage-os/scripts/retry

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
MAX_RETRIES=5
4+
COUNT=0
5+
6+
while true; do
7+
eval "$1"
8+
EXIT_CODE=$?
9+
if [ $EXIT_CODE -eq 0 ]; then
10+
exit 0
11+
fi
12+
13+
COUNT=$((COUNT + 1))
14+
if [ $COUNT -ge $MAX_RETRIES ]; then
15+
echo "Command failed after $MAX_RETRIES attempts."
16+
exit $EXIT_CODE
17+
fi
18+
19+
echo "Retry $COUNT/$MAX_RETRIES failed. Retrying..."
20+
sleep 1
21+
done
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
return [
8+
'db-host' => '127.0.0.1',
9+
'db-user' => 'magento-test',
10+
'db-password' => 'password',
11+
'db-name' => 'magento-test',
12+
'db-prefix' => '',
13+
'backend-frontname' => 'backend',
14+
'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
15+
'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
16+
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
17+
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
18+
'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
19+
];

0 commit comments

Comments
 (0)