Where can we put static contents on OpenShift ?
Environment
- OpenShift Online
Issue
- Where can we put static contents on OpenShift, such as html templates, images, pdfs etc ? Also this content shouldn't be modifies by git push command.
Resolution
data directory at app-root is a good place to keep the html templates. You can simply 'scp' the templates to that directory, for eg :
scp $FILE $UUID@$APPLICATION_NAME-$NAMESPACE.rhcloud.com:/var/lib/openshift/$UUID/app-root/data
if there is a directory try '-r' :
scp -r $DIR_NAME $UUID@$APPLICATION_NAME-$NAMESPACE.rhcloud.com:/var/lib/openshift/$UUID/app-root/data
The data directory is immune to git push and the content inside it do not change/delete during the push operations.
Note : If you have a scaled application, then please perform a load test to estimate the number of gears that you would need at peak load and based on that you can keep the minimum number of gears == maximum number of gears for your application, so that any given point of time you would have redundant instances available. Or you can choose to have manual scaling enabled.
So for putting a static content on scaled app, create a scaled application and keep the minimum gears as per your requirement, in below test we kept minimum to 3 and maximum to all available gears. Once done run commands as below :
[userone@test-machine testapp]$ rhc app-show testapp --gears
ID State Cartridges Size SSH URL
------------------------ ------- --------------------- ----- -------------------------------------------------------------------
UUID1 started jbosseap-6 haproxy-1.4 small UUID1@testapp-userone.rhcloud.com
UUID2 started jbosseap-6 haproxy-1.4 small UUID2@UUID2-userone.rhcloud.com
UUID3 started jbosseap-6 haproxy-1.4 small UUID3@UUID3-userone.rhcloud.com
You will see 3 instances spawned up for you and available at any given point of time. Now simply scp the files to the 'data' directory of the individual gears manually.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
