Chapter 9. OpenShift Build Process
When an application developer pushes changes to an application's Git repository, OpenShift Enterprise builds and deploys the application using the updated repository. The build and deploy process changes if the application is scaling or if it uses a builder cartridge.
9.1. Default Build Life Cycle Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
If no builder cartridge is present, OpenShift Enterprise executes the default build life cycle when an application developer pushes changes to an application Git repository. The default life cycle consists of a
build, preparation, distribute, and deploy phase.
In the default build life cycle, OpenShift Enterprise manages the starting and stopping of the application, and moves the updated code into
$OPENSHIFT_REPO_DIR. The primary cartridge and application developer action hooks ($OPENSHIFT_REPO_DIR/.openshift/action_hooks) determine specific behaviors during this process.
Build Phase
During this phase, OpenShift Enterprise:
- Runs the
gear stopcommand to stop the application. - Runs the
control pre-receivecommand on the primary cartridge. - Runs the
control pre-repo-archivecommand on the primary cartridge. - Creates a new application directory:
$OPENSHIFT_HOMEDIR/app-deployments/$date_$timeand dependent subdirectories.Note
If your cartridge requires a particular directory structure for dependencies, create a symbolic link for your cartridge directory structure into$OPENSHIFT_DEPENDENCIES_DIR. Use$OPENSHIFT_BUILD_DEPENDENCIES_DIRfor build time only dependencies. - Copies
$OPENSHIFT_HOMEDIR/app-root/runtime/dependenciesfrom the active application to$OPENSHIFT_HOMEDIR/app-deployments/$date_$time/dependencies. - Removes previous applications starting from the oldest until the number set at
$OPENSHIFT_KEEP_DEPLOYMENTSis reached. - Copies the new application source code to
$OPENSHIFT_REPO_DIR. This is the only point in the build life cycle when OpenShift Enterprise copies the application source code. - Runs the
control pre-buildcommand on the primary cartridge. - Runs the
pre-builduser action hook, if present. - Runs the
control buildcommand on the primary cartridge. - Runs the
builduser action hook, if present.
Preparation Phase
- OpenShift Enterprise runs the
prepareuser action hook, if present. - The application ID and checksum of application contents are calculated.
- OpenShift Enterprise creates
$OPENSHIFT_HOMEDIR/app-deployments/by-id/$deployment_idand points to../app-deployments/$date_time
Distribute Phase
- OpenShift Enterprise synchronizes the new application with all child gears if the application is scalable.
Deploy Phase
During this phase, OpenShift Enterprise:
- Updates
$OPENSHIFT_HOMEDIR/app-root/runtime/reposo it points to../../app-deployments/$date_$time/repo - Updates
$OPENSHIFT_HOMEDIR/app-root/runtime/dependenciesso it points to../../app-deployments/$date_$time/dependencies - Runs the
control update-configurationcommand on the primary cartridge. - Starts all secondary cartridges in the application.
- Runs the
control deploycommand on the primary cartridge. - Runs the
deployuser action hook, if present. - Starts the primary cartridge using the
gear startcommand. - Runs the
control post-deploycommand on the primary cartridge. - Runs the
post-deployuser action hook, if present.
Result:
The build is now complete and the application is running.