Adobe Commerce Cloud - Set up Magepack

Adobe Commerce Cloud - Set up Magepack

Goal

The goal is to use Magepack on the ACC instance.

Steps

Default hooks build configuration looks like the following: File: .magento.app.yaml

hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        composer install
        php ./vendor/bin/ece-tools run scenario/build/generate.xml
        php ./vendor/bin/ece-tools run scenario/build/transfer.xml

We need to install Node.js and generate the bundle. To do this, we need to change the file in the following way: File: .magento.app.yaml

hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        composer install
        unset NPM_CONFIG_PREFIX
        curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
        export NVM_DIR="$HOME/.nvm"
        [ -s "$NVM_DIR/nvm.sh"  ] && \. "$NVM_DIR/nvm.sh"
        nvm install --lts=erbium
        npm install -g magepack
        php ./vendor/bin/ece-tools build:generate
        echo "Generating magepack bundle..."
        magepack bundle
        php ./vendor/bin/ece-tools build:transfer

Now we need to make deployment and check if the commands execution was successful.