Application Upgrade Using Pre-Built Assets
On an upgrade, one of the most resource-consuming operations is JavaScript and CSS assets build. To speed up the upgrade process by up to 25%, you can provide pre-built assets together with the application source code. As a result, there will be no need to rebuild them in the OroCloud environment.
This guide shows how to configure the OroCloud environment to run the upgrade without assets build and how to store pre-built assets in a git repository.
Configure OroCloud
To make OroCloud skip the assets build during the upgrade, override upgrade commands in the orocloud.yaml file:
For OroCommerce 5.1 and higher:
---
orocloud_options:
deployment:
upgrade_commands:
- 'oro:platform:update'
- 'assets:install'
For OroCommerce 5.0 and lower:
---
orocloud_options:
deployment:
upgrade_commands:
- 'oro:platform:update --skip-assets'
- 'assets:install'
The
assets:install
command installs assets that are served directly, and should not be built. This operation is fairly quick.
Store Pre-Built Assets in a Git Repository
When the application is ready to be released, follow the two steps outlined below:
Change post-install-cmd Composer hook in composer.json file:
For OroCommerce 6.0 and higher remove next scripts:
@install-npm-assets @install-assets
For OroCommerce 5.1:
@auto-scripts @install-assets
Build assets locally:
php bin/console oro:assets:install --env=prod
Warning
Make sure you build assets in prod environment without
--skip-*
options. Otherwise, assets may be incomplete and not ready for the production use.Add built assets to the git repository.
In OroCommerce 4.1 and higher, built assets are placed in the public/ folder. By default, they are added into the .gitignore file and not tracked by git.
If you want to add them to the git repository, you have two options:
Remove the following lines for the .gitignore file to track changes on the built assets:
For OroCommerce 4.2 and higher:
/public/js/* /public/build /public/media/js
For OroCommerce 4.1:
/public/js /public/build /public/layout-build /public/media/js
Force the addition of the built assets to the git repository when they are ready.
For OroCommerce 4.2 and higher:
git add -f public/build public/js/oro.locale_data.js public/media/js
For OroCommerce 4.1:
git add -f public/build public/layout-build public/js/oro.locale_data.js public/media/js
Note
To avoid a large number of changed files during development, it is recommended that you do not store pre-built assets in the dev branches and add them only to the release branches or tags.
After pushing pre-built assets to the git repository, you can run an upgrade with one of the maintenance commands.
Warning
It is required to rebuild assets every time before the upgrade. Otherwise, you can end up with outdated or broken styles and javascript assets on your website.