Basic deployment tips
How deployment works
The command to create a new app and to push a new version of an existing one are the same:
cf push. The basic steps:
Set up your local directory with the code you want to deploy. For example, if you use Git or another version control system, check out the version of the code you want to deploy:
git checkout master
cf target -o <SOMEORG> -s <SOMESPACE>
Deploy the application:
cf push <APPNAME>
The app should now be live at
Application architecture recommendations
To avoid surprises, here are basic architecture principles for this cloud environment.
See Cloud Foundry’s Considerations for Designing and Running an Application in the Cloud – these apply to cloud.gov as well. As they say, applications will be easiest to deploy if they follow the Twelve-Factor App guidelines.
Once you get a sense of these, check out the production-ready guide as well.
Avoid writing to the local file system
Don’t depend on local file system storage. When your application restarts (for example, if you restart it, or if the platform automatically restarts it for you), files on the local filesystem will disappear. Instead, use a storage service.
The platform may restart your application
cloud.gov will automatically restart your application instances occasionally. For example, instances will be restarted if they exceed memory limits, and they may be restarted when the cloud.gov platform is updated.
Check your log configuration
Proper logging might require special libraries/configuration for your app.
Set environment variables
See Cloud Foundry’s documentation on environment variables.
Ignore unnecessary files when pushing
cloud.gov isn’t version-control-aware, so
cf push will deploy the working state of whatever files you have in that directory. In most cases, you will want to exclude files ignored by Git. From within your project directory, run
ln -s .gitignore .cfignore
and commit the
.cfignore to your repository. However, read on if you have a more advanced CF setup.
A couple of important points on the
- If you have a more advanced app setup and have apps with a
pathother than the project root (where you run
cf pushfrom), you will need an additional
.cfignorefile located in each app
- Also note that more advanced
.gitignoresyntax, such as the
**recursive subdirectory wildcard, are not supported by