magesuite / magepack

Next generation Magento 2 advanced JavaScript bundler.
Open Software License 3.0
431 stars 93 forks source link

We had a problem with Magento Cloud during launch "magepack generate" #137

Open sekam opened 2 years ago

sekam commented 2 years ago

We had a problem with Magento Cloud during launch "magepack generate"

W:
W: ERROR Failed to launch the browser process!
W: /app/.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libXcomposite.so.1: cannot open shared object file: No such file or directory

We added in the .magento.app.yaml (by recommendations https://support.magento.com/hc/en-us/articles/360022507012-Configure-NPM-to-be-able-to-use-PWA-Studio)

hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        echo "Node Js Version re: MDVA-29720"
        node --version
        echo "Installing NVM"
        unset NPM_CONFIG_PREFIX
        curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
        export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
        [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
        nvm install 10
        nvm use 10
        echo "Node Js Version re: MDVA-29720"
        node --version
        npm install -g magepack
krzksz commented 2 years ago

Hey, it is not advised to run bundle generation during CI. You can do that, but as you can see it is problematic and I am unable to support all server configurations to make it work for everybody.

Ideally, you should generate configuration locally, commit magepack.config.js file to the repo and use it to bundle during CI.

fredden commented 2 years ago

You may like to add npm config set puppeteer_skip_chromium_download true -g before npm install -g magepack. This is what we use with success on Cloud to run magepack bundle. (We run magepack generate locally and commit magepack.config.js per above recommendation.)

The snippet you pasted above from .magento.app.yaml doesn't include running any magepack commands, so it's hard to see what's going on / help you further. Here's a known-working 'build' step:

    build: |
        set -e
        unset NPM_CONFIG_PREFIX
        curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.1/install.sh | bash
        export NVM_DIR="$HOME/.nvm"
        [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
        nvm install 12.13
        npm config set puppeteer_skip_chromium_download true -g
        npm install magepack -g
        php ./vendor/bin/ece-tools build:generate
        magepack bundle
        php ./vendor/bin/ece-tools build:transfer
mrtuvn commented 1 year ago

hi @fredden. Interesting problem Is this may cause fail building cloud ? without text "npm config set puppeteer_skip_chromium_download true -g" build process will fail