# Managing Buildpacks

## Introduction

Todo

## Deploying a Node.js app to Cloud Foundry (IBM Bluemix)

Deploying a Node.js application to Cloud Foundry is fairly simple. For simplicity and speed in getting started, we have omitted a lot of the customizable features of Cloud Foundry deployment and are relying on system defaults. Since Cloud Foundry has a system-provided Node.js buildpack, Bluemix is able to automatically detect and deploy Node.js applications without much work on the developer’s part. For an understanding of how buildpacks work, see Introduction to Cloud Foundry Buildpacks.

* Step 1 - Download and install Cloud Foundry CLI tool
* Step 2 - Use CF CLI to push your application to Bluemix

  Having installed CF CLI, navigate to the folder that contains your application.

  In your terminal run the following commands:

```
cf api https://api.ng.bluemix.net/
cf login
cf push yourAppName
```

* Step 3 - Done! Log into Bluemix’s dashboard and look in your workspace.

**Requirements:** App must have a package.json in the root folder for it to be detected as a Node.js app. You need an IBM Bluemix account for the above example to work. Set cf api to your Cloud Foundry instance if you are not using Bluemix.

**Tips:** Don’t worry about having a manifest.yml for a simple application, Bluemix will use system defaults if you do not have one. If you find you need a manifest.yml, follow these guidelines. For deeper understanding of customizing your node deployment, read this.

**References:** <https://docs.cloudfoundry.org/buildpacks/node/> <https://docs.cloudfoundry.org/buildpacks/node/node-tips.html> <https://www.ibm.com/developerworks/cloud/library/cl-bluemix-fundamentals-create-and-deploy-a-node-app-to-the-cloud/> <http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html>

## Introduction to Cloud Foundry Buildpacks

Cloud Foundry relies on buildpacks to build and deploy applications. Buildpacks are used to automate detection of an application’s framework, compilation, and deployment. Each Cloud Foundry instance has a set of built in system buildpacks, but can also accept user-defined buildpacks.

A buildpack at its core is a set of three scripts:

```
bin/detect
bin/compile
bin/release
```

When an application is uploaded to Cloud Foundry, it will run through each buildpack’s detect script in sequence in order to determine which buildpack is appropriate for the application. It will then run the compile and release scripts of the first detect script which returns an affirmative exit code. Due to this detect order, buildpack ordering becomes important when deploying applications with multiple frameworks.

### System buildpacks

By default Cloud Foundry has the following buildpacks which will be checked in order:

* Java
* Ruby
* Node.js
* Binary
* Go
* PHP
* Python
* Staticfile

### Custom buildpacks

In order to use a custom buildpack that is not in your Cloud Foundry instance, you can use the -b flag in order to define a github repo where the custom buildpack is located when you push your application.

```
cf push appName -b url
```

**example:** `cf push appName -b https://github.com/cloudfoundry/nodejs-buildpack`

Here is a list of community written custom buildpacks: <https://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks>

If you have administrator privileges on your Cloud Foundry instance, you can upload custom buildpacks to it and define its order position in the detection sequence. <http://docs.cloudfoundry.org/adminguide/buildpacks.html>

### References and additional reading:

<http://blog.altoros.com/creating-a-custom-cloud-foundry-buildpack-from-scratch-whats-under-the-hood.html> <http://mikusa.blogspot.com/2013/11/cloudfoundry-build-packs-introduction.html> <http://docs.cloudfoundry.org/buildpacks/> <http://docs.cloudfoundry.org/adminguide/buildpacks.html> <https://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cedrus.gitbook.io/codesoju/managing-buildpacks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
