GSS-Cogs / dd-cms

A data-driven content management system prototype, based on Plone/Volto and data blocks
2 stars 0 forks source link

Volto Docker build needs refactoring #91

Closed ajtucker closed 2 years ago

ajtucker commented 2 years ago

The image is nearly 3GB and could do with using multi-stage build and better use of image layers so that e.g. yarn develop and yarn install only need to be run when package.json (& lockfile) change.

The yarn test step currently seems to overload our server.

ajtucker commented 2 years ago

Hey team! Please add your planning poker estimate with ZenHub @cjfairchild @charlesons @rossbowen @TahaRana97 @osamede20

ajtucker commented 2 years ago

I missed saying that I'd had a look at some multi-stage build things in https://github.com/GSS-Cogs/dd-cms/blob/volto-docker/volto/Dockerfile

ajtucker commented 2 years ago

A couple of minor issues with yarn.lock and .dockerignore in #99

ajtucker commented 2 years ago

Fixed yarn test in Jenkins by #100.

Still to look at multi-stage build for the main Volto Docker images.

ajtucker commented 2 years ago

I've added some minor changes to https://github.com/GSS-Cogs/dd-cms/blob/volto-docker/volto/Dockerfile#L17 to get a multi-stage build that uses a similar approach to the test Dockerfile image.

The current issue is that the Razzle build (yarn -s build line) is meant to make a self-contained app in the build directory which can be run directly with node ./server.js, but there are still some external dependencies that haven't been bundled, e.g. lodash from the govuk-react-jsx package.

@nosnickid, this is probably one for you?

nosnickid commented 2 years ago

sure, i'll pick this one up

nosnickid commented 2 years ago

Seems like the deployment depends on the node_modules being deployed along with the built assets.

That's totally opposite to what you would expect from a 'built' output, but the azure deployment docs definitely include them - see "Zip the Razzle project":

https://razzlejs.org/deployment-options/azure

nosnickid commented 2 years ago

On the other hand, the plesk docs explicitly don't include the node_modules!

https://razzlejs.org/deployment-options/plesk

nosnickid commented 2 years ago

Oh, for plesk the instructions have a 'Run NPM install step'.

So I'll just tweak the Dockerfile to include node_modules.

nosnickid commented 2 years ago

@ajtucker this should be ready for you to try again now.

cjfairchild commented 2 years ago

I've done some minor tweaks to the Jenkinsfile and forced the pipeline to run in Jenkins - reducing run time and RAM utilisation significantly. It appears the HTML publishing plugin in Jenkins was attempting to archive all of the files in the build/test context in a heap in Java, which was causing OOM errors.

See branch ci-di for more. Suggested Changes are in a PR for Restricting Jest tests.