Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud installation #135

Open
DDasalgado0391 opened this issue Feb 18, 2022 · 7 comments
Open

Cloud installation #135

DDasalgado0391 opened this issue Feb 18, 2022 · 7 comments

Comments

@DDasalgado0391
Copy link

Hi,
I'm trying to install this on a cloud project following the steps provided here:

I updated the magento.app.yaml file in the post_deploy section including this:

echo "\n================================== Install and configure Magepack - Start ==============================="
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 --lts=dubnium
npm install -g magepack
echo "\n================================== create bundle ==============================="
magepack bundle
echo "\n================================== Install and configure Magepack - END ================================="

However during the deployment I got these error messages:

  “n================================== Install and configure Magepack – Start ===============================”
    W:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    W:                                  Dload  Upload   Total   Spent    Left  Speed

100 13527 100 13527 0 0 252k 0 --:--:-- --:--:-- --:--:-- 254k
=> Downloading nvm from git to '/app/.nvm'
W: mkdir: cannot create directory ‘/app/.nvm’: Read-only file system
W: ls: cannot access '/app/.nvm': No such file or directory
W: fatal: could not create work tree dir '/app/.nvm': Read-only file system
W: Failed to clone nvm repo. Please report this!
W: /bin/dash: 7: nvm: not found
W: npm ERR! Linux 4.19.205-0psh2
W: npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "magepack"
W: npm ERR! node v6.17.1
W: npm ERR! npm v3.10.10
W: npm ERR! path /app/.npm
W: npm ERR! code EROFS
W: npm ERR! errno -30
W: npm ERR! syscall mkdir
W:
W: npm ERR! rofs EROFS: read-only file system, mkdir '/app/.npm'
W: npm ERR! rofs This is most likely not a problem with npm itself
W: npm ERR! rofs and is related to the file system being read-only.
W: npm ERR! rofs
W: npm ERR! rofs Often virtualized file systems, or other file systems
W: npm ERR! rofs that don't support symlinks, give this error.
W: npm ERR! Linux 4.19.205-0psh2
W: npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "magepack"
W: npm ERR! node v6.17.1
W: npm ERR! npm v3.10.10
W: npm ERR! path npm-debug.log.4141927588
W: npm ERR! code EROFS
W: npm ERR! errno -30
W: npm ERR! syscall open
W:
W: npm ERR! rofs EROFS: read-only file system, open 'npm-debug.log.4141927588'
W: npm ERR! rofs This is most likely not a problem with npm itself
W: npm ERR! rofs and is related to the file system being read-only.
W: npm ERR! rofs
W: npm ERR! rofs Often virtualized file systems, or other file systems
W: npm ERR! rofs that don't support symlinks, give this error.
W:
W: npm ERR! Please include the following file with any support request:
W: npm ERR! /app/npm-debug.log
=> “n================================== create bundle ===============================”
W: /bin/dash: 10: magepack: not found
“n================================== Install and configure Magepack – END =================================”

is any other configuration required?
Thanks

@fredden
Copy link
Contributor

fredden commented Feb 22, 2022

We have success on Cloud by putting magepack bundle (and related commands) into the 'build' step. When the 'post_deploy' step runs, the application has already been compiled and deployed; it's too late to set up magepack then.

@DDasalgado0391
Copy link
Author

Hi, I added the commands there and this is the deployment result:

    [2022-02-23 21:47:10] INFO: Scenario(s) finished
    W:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    W:                                  Dload  Upload   Total   Spent    Left  Speed

100 13527 100 13527 0 0 62665 0 --:--:-- --:--:-- --:--:-- 62916
=> Downloading nvm from git to '/app/.nvm'
W: Cloning into '/app/.nvm'...
=> => Compressing and cleaning up git repository

    => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
    => Create one of them and run this script again
       OR
    => Append the following lines to the correct file yourself:
    
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    
    => Installing Node.js version v16.14.0
    Downloading and installing node v16.14.0...
    W: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...

######################################################################## 100.0%
W: Computing checksum with sha256sum
W: Checksums matched!
Now using node v16.14.0 (npm v8.3.1)
Creating default alias: default -> v16.14.0 *
=> Node.js version v16.14.0 has been successfully installed
=> Close and reopen your terminal to start using nvm or run the following to use it now:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    Installing with latest version of LTS line: dubnium
    Downloading and installing node v10.24.1...
    W: Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-x64.tar.xz...

######################################################################## 100.0%
W: Computing checksum with sha256sum
W: Checksums matched!
Now using node v10.24.1 (npm v6.14.12)
W: npm WARN deprecated puppeteer@2.1.1: Version no longer supported. Upgrade to @latest
/app/.nvm/versions/node/v10.24.1/bin/magepack -> /app/.nvm/versions/node/v10.24.1/lib/node_modules/magepack/cli.js

    > puppeteer@2.1.1 install /app/.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/puppeteer
    > node install.js
    
    W: 
    Chromium downloaded to /app/.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/puppeteer/.local-chromium/linux-722234
    + magepack@2.8.0
    added 61 packages from 77 contributors in 10.027s
    ℹ Using bundling config from "/app/magepack.config.js".
    W: 
    W:  ERROR  No locales found! Make sure magepack is running after static content is deployed.
    W: 
    W:   at getLocales (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/lib/bundle/getLocales.js:21:15)
    W:   at module.exports (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/lib/bundle.js:27:26)
    W:   at Command.program.command.description.option.option.option.option.option.action (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/cli.js:58:32)
    W:   at Command.listener [as _actionHandler] (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/commander/index.js:413:31)
    W:   at Command._parseCommand (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/commander/index.js:914:14)
    W:   at Command._dispatchSubcommand (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/commander/index.js:865:18)
    W:   at Command._parseCommand (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/commander/index.js:882:12)
    W:   at Command.parse (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/node_modules/commander/index.js:717:10)
    W:   at Object.<anonymous> (.nvm/versions/node/v10.24.1/lib/node_modules/magepack/cli.js:63:9)
    W:   at Module._compile (internal/modules/cjs/loader.js:778:30)
    W: 
  
  E: Error building project: Step failed with status code 1.

E: Error: Unable to build application, aborting.

Do I need to add something else in the magento.app.yaml file?

@fredden
Copy link
Contributor

fredden commented Feb 25, 2022

Can you post the (relevant) contents of your .magento.app.yaml file? I'd expect to see something like the following:

hooks:
    build: |
        set -e
        unset NPM_CONFIG_PREFIX
        curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
        export NVM_DIR="$HOME/.nvm"
        [ -s "$NVM_DIR/nvm.sh"  ] && \. "$NVM_DIR/nvm.sh"
        nvm install 16
        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
    deploy: |
        php ./vendor/bin/ece-tools deploy
    post_deploy: |
        php ./vendor/bin/ece-tools post-deploy

See the section that mentions that "you can customize the build phase" on the Adobe Commerce Developer Guide regarding .magento.app.yaml.

@DDasalgado0391
Copy link
Author

DDasalgado0391 commented Feb 25, 2022

Hi,
This is the hooks section of the magento.app.yaml

hooks: # We run build hooks before your application has been packaged. 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 16 npm config set puppeteer_skip_chromium_download true -g echo "\n================================== install magepack ===============================" npm install magepack -g echo "\n================================== build generate ===============================" php ./vendor/bin/ece-tools run scenario/build/generate.xml echo "\n================================== magepack bundle ===============================" magepack bundle echo "\n================================== build transfer ===============================" php ./vendor/bin/ece-tools run scenario/build/transfer.xml # We run deploy hook after your application has been deployed and started. deploy: | php ./vendor/bin/ece-tools run scenario/deploy.xml # We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10. post_deploy: | php ./vendor/bin/ece-tools run scenario/post-deploy.xml

The deployment result was:

` Executing build hook...
W: % Total % Received % Xferd Average Speed Time Time Time Current
W: Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 65703 0 --:--:-- --:--:-- --:--:-- 65985
=> Downloading nvm from git to '/app/.nvm'
W: Cloning into '/app/.nvm'...
=> => Compressing and cleaning up git repository

    => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
    => Create one of them and run this script again
       OR
    => Append the following lines to the correct file yourself:
    
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    
    => Installing Node.js version v16.14.0
    Downloading and installing node v16.14.0...
    W: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...

######################################################################## 100.0%
W: Computing checksum with sha256sum
W: Checksums matched!
Now using node v16.14.0 (npm v8.3.1)
Creating default alias: default -> v16.14.0 *
=> Node.js version v16.14.0 has been successfully installed
=> Close and reopen your terminal to start using nvm or run the following to use it now:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    W: v16.14.0 is already installed.
    Now using node v16.14.0 (npm v8.3.1)
    
    ================================== install magepack ===============================
    W: npm WARN deprecated puppeteer@2.1.1: Version no longer supported. Upgrade to @latest
    
    added 61 packages, and audited 62 packages in 2s
    
    1 package is looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    
    ================================== build generate ===============================
    [2022-02-25 17:01:40] INFO: Starting scenario(s): scenario/build/generate.xml (magento/ece-tools version: 2002.1.8, magento/magento2-base version: 2.4.3-p1)
    [2022-02-25 17:01:40] INFO: Verbosity level is not set
    [2022-02-25 17:01:40] NOTICE: Applying patches
    [2022-02-25 17:01:41] NOTICE: End of applying patches
    [2022-02-25 17:01:41] INFO: Set Magento application mode to 'production'
    [2022-02-25 17:01:41] NOTICE: Validating configuration
    [2022-02-25 17:01:42] NOTICE: Fix configuration with given suggestions:
    [2022-02-25 17:01:42] WARNING: [1006] The configured state is not ideal
    No stores/website/locales found in config.php
      To speed up the deploy process do the following:
      1. Using SSH, log in to your Magento Cloud account
      2. Run "php ./vendor/bin/ece-tools config:dump"
      3. Using SCP, copy the app/etc/config.php file to your local repository
      4. Add, commit, and push your changes to the app/etc/config.php file
    
    Your application does not have the "post_deploy" hook enabled.
      In order to minimize downtime, add the following to ".magento.app.yaml":
      hooks:
          post_deploy: |
              php ./vendor/bin/ece-tools run scenario/post-deploy.xml
    [2022-02-25 17:01:42] NOTICE: End of validation
    [2022-02-25 17:01:42] NOTICE: Reconciling installed modules with shared config.
    [2022-02-25 17:02:07] INFO: No modules were changed.
    [2022-02-25 17:02:07] NOTICE: End of reconciling modules.
    [2022-02-25 17:02:07] INFO: File "front-static.php" was copied
    [2022-02-25 17:02:07] INFO: Configuring directory nesting level for saving error reports
    [2022-02-25 17:02:07] NOTICE: The file /app/pub/errors/local.xml with the `config.report.dir_nesting_level` property: `1` was created.
    [2022-02-25 17:02:07] INFO: Sample data media was not found. Skipping.
    [2022-02-25 17:02:07] NOTICE: Running DI compilation
    [2022-02-25 17:05:12] NOTICE: End of running DI compilation
    [2022-02-25 17:05:24] NOTICE: Skipping static content deploy: No stores/website/locales found in config.php
    [2022-02-25 17:05:24] INFO: Scenario(s) finished
    
    ================================== magepack bundle ===============================
    ℹ Using bundling config from "/app/magepack.config.js".
    W: (node:4239) [DEP0128] DeprecationWarning: Invalid 'main' field in '/app/.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/generate-sourcemap/package.json' of 'generate-sourcemap.js'. Please either fix that or report it to the module author
    W: (Use `node --trace-deprecation ...` to show where the warning was created)
    W: 
    W:  ERROR  No locales found! Make sure magepack is running after static content is deployed.
    W: 
    W:   at getLocales (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/lib/bundle/getLocales.js:21:15)
    W:   at module.exports (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/lib/bundle.js:27:26)
    W:   at Command.<anonymous> (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/cli.js:58:32)
    W:   at Command.listener [as _actionHandler] (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/commander/index.js:413:31)
    W:   at Command._parseCommand (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/commander/index.js:914:14)
    W:   at Command._dispatchSubcommand (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/commander/index.js:865:18)
    W:   at Command._parseCommand (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/commander/index.js:882:12)
    W:   at Command.parse (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/node_modules/commander/index.js:717:10)
    W:   at Object.<anonymous> (.nvm/versions/node/v16.14.0/lib/node_modules/magepack/cli.js:63:9)
    W:   at Module._compile (node:internal/modules/cjs/loader:1103:14)
    W: 
  
  E: Error building project: Step failed with status code 1.

E: Error: Unable to build application, aborting.`

@fredden
Copy link
Contributor

fredden commented Feb 25, 2022

Great, it looks like we're making progress. The 'hooks' section looks good (formatting here makes it hard to read, but I think it matches the known-working snippet I'd posted where relevant).
The problem seems to be that there are no stores/websites/locales in app/etc/config.php. See this line in your output from Magento:

[2022-02-25 17:05:24] NOTICE: Skipping static content deploy: No stores/website/locales found in config.php

It looks like you need to set up static content deployment on the build step. This is step two in the zero downtime deployment guide.

See also the output of php vendor/bin/ece-tools wizard:ideal-state.

@convenient
Copy link

Hey @fredden bit of a blast from the past for you :)

Am I misunderstand this bit

        php ./vendor/bin/ece-tools build:generate
        magepack bundle
        php ./vendor/bin/ece-tools build:transfer
    deploy: |
        php ./vendor/bin/ece-tools deploy
    post_deploy: |
        php ./vendor/bin/ece-tools post-deploy

In this process you are running magepack bundle and it will have had references to https://example.com/product-page and similar for each type of page.

Those requests being made will be against the live version of the codebase and not the version you are in the process of deploying? My understanding is that you would always be generating magepack on the version that is live, and therefor potentially be 1 step behind?

@fredden
Copy link
Contributor

fredden commented Mar 5, 2024

@convenient hello again. :)

I think you're confusing magepack generate with magepack bundle. The former (generate) will visit the website referenced and create / overwrite magepack.config.js. The latter (bundle) will read the files in pub/static/ and create "bundles" with concatenated (and ususally minified) versions of the same. There are no HTTP requests involved with the bundle command. Running generate is a step which should be done as part of the development cycle, and magepack.config.js should be committed to the repository so it's available for bundle to run correctly in the deployment process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants