Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 7 additions & 33 deletions .devcontainer/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu
# ======================================================================================
# Environment and Service Configuration
# ======================================================================================
USE_MAGEOS="${USE_MAGEOS:=YES}"
PLATFORM_NAME="${PLATFORM_NAME:=mage-os}" # Options: mage-os, magento
INSTALL_MAGENTO="${INSTALL_MAGENTO:=YES}"
INSTALL_SAMPLE_DATA="${INSTALL_SAMPLE_DATA:=YES}"
HYVA_LICENCE_KEY="${HYVA_LICENCE_KEY:=}"
Expand All @@ -29,13 +29,6 @@ show_ready_message() {
echo "Have an awesome time! 💙 Develo.co.uk"
}

# Determine platform name for display
if [ "${USE_MAGEOS}" = "YES" ]; then
PLATFORM_NAME="mage-os"
else
PLATFORM_NAME="magento"
fi

# ======================================================================================
# Supervisor Services (Nginx, MariaDB, Redis)
# ======================================================================================
Expand Down Expand Up @@ -90,10 +83,10 @@ else
TEMP_DIR=$(mktemp -d)
echo "Using temporary directory: ${TEMP_DIR}"

if [ "${USE_MAGEOS}" = "YES" ]; then
if [ "${PLATFORM_NAME}" = "mage-os" ]; then
echo "Installing Mage-OS from https://repo.mage-os.org/"
${COMPOSER_COMMAND} create-project --repository-url=https://repo.mage-os.org/ mage-os/project-community-edition ${TEMP_DIR} --no-interaction
else
elif [ "${PLATFORM_NAME}" = "magento" ]; then
echo "Installing Magento from https://repo.magento.com/"
if [ -n "${MAGENTO_COMPOSER_AUTH_USER}" ] && [ -n "${MAGENTO_COMPOSER_AUTH_PASS}" ]; then
${COMPOSER_COMMAND} config --global http-basic.repo.magento.com ${MAGENTO_COMPOSER_AUTH_USER} ${MAGENTO_COMPOSER_AUTH_PASS}
Expand Down Expand Up @@ -129,7 +122,7 @@ else
# Install Sample Data if enabled
if [ "${INSTALL_SAMPLE_DATA}" = "YES" ]; then
echo "============ Installing Sample Data =========="
if [ "${USE_MAGEOS}" = "YES" ]; then
if [ "${PLATFORM_NAME}" = "mage-os" ]; then
echo "**** Deploying Mage-OS sample data ****"
# Mage-OS uses the same sample data as Magento
${COMPOSER_COMMAND} require mage-os/module-bundle-sample-data mage-os/module-widget-sample-data mage-os/module-theme-sample-data mage-os/module-catalog-sample-data mage-os/module-customer-sample-data mage-os/module-cms-sample-data mage-os/module-catalog-rule-sample-data mage-os/module-sales-rule-sample-data mage-os/module-review-sample-data mage-os/module-tax-sample-data mage-os/module-sales-sample-data mage-os/module-grouped-product-sample-data mage-os/module-downloadable-sample-data mage-os/module-msrp-sample-data mage-os/module-configurable-sample-data mage-os/module-product-links-sample-data mage-os/module-wishlist-sample-data mage-os/module-swatches-sample-data --no-update
Expand Down Expand Up @@ -186,7 +179,7 @@ else
php -d memory_limit=-1 bin/magento setup:upgrade
fi

if [ "${HYVA_LICENCE_KEY+x}" ]; then
if [ "${HYVA_LICENCE_KEY}" ]; then
echo "**** Configuring Hyvä Theme ****"
${COMPOSER_COMMAND} config --auth http-basic.hyva-themes.repo.packagist.com token ${HYVA_LICENCE_KEY}
${COMPOSER_COMMAND} config repositories.private-packagist composer https://hyva-themes.repo.packagist.com/${HYVA_PROJECT_NAME}/
Expand Down Expand Up @@ -235,8 +228,6 @@ fi;
# unzip -o ${CODESPACES_REPO_ROOT}/bam_media.zip -d ${CODESPACES_REPO_ROOT}/pub/ && rm ./bam_media.zip
fi

show_ready_message

touch "${CODESPACES_REPO_ROOT}/.devcontainer/db-installed.flag"

if [ "${HYVA_LICENCE_KEY}" ]; then
Expand Down Expand Up @@ -291,33 +282,16 @@ fi;
# ======================================================================================
# Fix for missing sample data media files
# ======================================================================================
if [ "${INSTALL_SAMPLE_DATA}" = "YES" ]; then
if [ "${INSTALL_SAMPLE_DATA}" = "YES" ] && [ "${PLATFORM_NAME}" = "mage-os" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample data can be installed on both platforms.

Revert this back to
if [ "${INSTALL_SAMPLE_DATA}" = "YES" ]; then

Then use the platform_name value here
SAMPLE_MEDIA_SOURCE="vendor/${PLATFORM_NAME}/sample-data-media"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand you, but this fix is only for MageOS, meaning there’s no such issue for Luma.
So this condition is completely justified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the Sample data is available for both MageOS and Magento, and also works for Luma and Hyvä as the product images are the same

SAMPLE_MEDIA_SOURCE="vendor/mage-os/sample-data-media"
MEDIA_DEST="pub/media"

if [ -d "$SAMPLE_MEDIA_SOURCE" ] && [ -w "$MEDIA_DEST" ]; then
echo "Found sample data media. Copying to pub/media..."
rsync -a "${SAMPLE_MEDIA_SOURCE}/" "${MEDIA_DEST}/"

if [ -f "bin/magento" ]; then
echo "Resizing product images and flushing cache..."
php -d memory_limit=-1 bin/magento catalog:image:resize
php -d memory_limit=-1 bin/magento cache:flush
echo "Sample data media fix applied."
fi
else
echo "Sample data media source not found or pub/media not writable. Skipping fix."
fi
fi


# ======================================================================================
# Environment Ready Message
# ======================================================================================
show_ready_message() {
echo "============ Environment Ready =========="
echo "All services started successfully!"
echo "You can check service status with: .devcontainer/scripts/status.sh"
echo "And Docker containers with: docker ps"
echo "Have an awesome time! 💙 Develo.co.uk"
}
show_ready_message