Skip to content

Commit b9d36b9

Browse files
WIP
1 parent c61fd53 commit b9d36b9

17 files changed

+415
-14
lines changed

mage-os/Dockerfile

Lines changed: 7 additions & 14 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,7 +20,7 @@ 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 && \
23+
curl -o mage-os.zip https://repo.mage-os.org/packages/mage-os/magento-$MAGEOS_TYPE-$MAGEOS_VERSION.zip && \
3024
unzip -q mage-os.zip -d . && \
3125
rm mage-os.zip; \
3226
echo "[cad] Allowing composer plugins" && \
@@ -74,16 +68,15 @@ COPY templates/install-config-mysql.php dev/tests/integration/etc/
7468
COPY templates/post-install-setup-command-config.php dev/tests/integration/etc/
7569
COPY entrypoint.sh entrypoint.sh
7670

77-
COPY scripts/enable-flat-catalog enable-flat-catalog
7871
COPY scripts/change-base-url change-base-url
7972
COPY scripts/install-composer-package install-composer-package
8073
COPY scripts/disable-2fa disable-2fa
8174

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
75+
#COPY templates/phpunit-integration.xml dev/tests/integration/phpunit.xml
76+
#COPY templates/phpunit-integration-248.xml dev/tests/integration/phpunit-248.xml
77+
#COPY templates/phpunit-unit.xml dev/tests/unit/phpunit.xml
78+
#COPY templates/phpunit-unit-248.xml dev/tests/unit/phpunit-248.xml
79+
#COPY scripts/fix-phpunit.xml.php fix-phpunit.xml.php
8780

8881
RUN chmod +x enable-flat-catalog && \
8982
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)