plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
479 stars 649 forks source link

Volto production docker builds failure with webpack error #3101

Closed arky closed 2 years ago

arky commented 2 years ago

Volto production builds fails in docker.

To Reproduce Steps to reproduce the behavior:

  1. Checkout plone volto training github repo https://github.com/collective/training-deploy-project
  2. Change directory to local root directory of the repo.
  3. Initialize a new volto code base and use 'frontend' default addon name.
  4. Change directory into 'frontend' and yarn install and yarn start
  5. Build a new frontend container with 'make build-image)

Expected behavior Docker build fails with webpack module missing error. How docker builds succeed if you remove '--prod' entry in the dockerfile https://github.com/collective/training-deploy-project/blob/main/frontend/Dockerfile#L16


$ yarn omelette && yarn patches
yarn run v1.22.17
$ ln -sf node_modules/@plone/volto/ omelette
Done in 0.04s.
yarn run v1.22.17
$ /bin/bash patches/patchit.sh > /dev/null 2>&1 ||true
Done in 0.04s.
Done in 238.86s.
Removing intermediate container e1d6cbd070f7
 ---> 37d81c8602db
Step 7/15 : COPY . .
 ---> f1f52f7ed646
Step 8/15 : RUN yarn build
 ---> Running in 20e6291a3aff
yarn run v1.22.17
$ razzle build
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'webpack'
Require stack:
- /usr/src/app/node_modules/mini-css-extract-plugin/dist/index.js
- /usr/src/app/node_modules/mini-css-extract-plugin/dist/cjs.js
- /usr/src/app/node_modules/razzle/config/createConfigAsync.js
- /usr/src/app/node_modules/razzle/scripts/build.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/usr/src/app/node_modules/mini-css-extract-plugin/dist/index.js:8:39)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/src/app/node_modules/mini-css-extract-plugin/dist/index.js',
    '/usr/src/app/node_modules/mini-css-extract-plugin/dist/cjs.js',
    '/usr/src/app/node_modules/razzle/config/createConfigAsync.js',
    '/usr/src/app/node_modules/razzle/scripts/build.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command '/bin/sh -c yarn build' returned a non-zero code: 1

**Software (please complete the following information):**

- OS: Ubuntu 
- Browser  Firefox
- Volto Version  14 (Stable) and 15(Alpha8)
- Plone Version  6-Dev
- 
**Additional context**

Downstream bug https://github.com/collective/training-deploy-project/issues/4
arky commented 2 years ago

@ericof I had better luck with production builds with following command.

yarn install --frozen-lockfile --no-cache --production
ericof commented 2 years ago

I will test it as well

arky commented 2 years ago

Resolved by using the command in https://github.com/plone/volto/issues/3101#issuecomment-1055624497