Your application gets built during the build phase, using the configuration files committed to the code repository and the core building configuration in .platform.app.yaml
. The following events happen during the build phase:
Build Hook
The build hook can be used to run commands that retrieve dependencies and build the application
hooks:
build: |
npm run setup-assets
npm run build
It can even be used to download and setup external libraries as shown in setting up custom Node.js versions. For further examples, review the language specific setup docs and our existing templates
Build Flavor
For some languages (e.g. Node.js and PHP), a build flavor is available that specifies a default set of build tasks to run. Below shows the commands the default build flavor runs if the dependency file exists
- Node.js (if
package.json
exists)
npm prune --userconfig .npmrc && npm install --userconfig .npmrc
- PHP (if
composer.json
exists)
composer --no-ansi --no-interaction install --no-progress --prefer-dist --optimize-autoloader
For languages with a build flavor, you can remove the default build flavor and run your own commands for complete control over your build
- Set the build flavor to
none
- Add the commands you need to your build hook, as in the following example:
build:
flavor: none
hooks:
build: |
set -e
composer install --no-interaction --no-dev
Further References
- Build and Deploy phase: overview of the steps involved in both the build and deploy phases
- Using build and deploy hooks: sample usage of build and deploy hooks for an example application
- Comparison of hooks: see what resources are available for each hook and how it affects the application