A Cloud Foundry buildpack for running arbitrary binary web servers.
Additional information can be found at CloudFoundry.org.
Unlike most other Cloud Foundry buildpacks, the binary buildpack must be specified in order for it to be used in staging your binary file. You can specify the buildpack your app should use with the -b option for cf push:
cf push my_app -b https://github.com/cloudfoundry/binary-buildpack.gitThere are two ways to provide Cloud Foundry with the shell command to execute your binary:
Include in your app's root directory a Procfile that specifies a web task:
web: ./appAlternatively, you can provide the start command when deploying your app with cf push by including a -c option:
cf push my_app -c './app' -b binary-buildpackYour binary is expected to bind to the port specified in the PORT environment variable. Here is an example in Go:
package main
import (
"fmt"
"net/http"
"os"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s", "world!")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":"+os.Getenv("PORT"), nil)
}Your binary should run without any additional runtime dependencies on the cflinuxfs2 or lucid64 root filesystem (rootfs). Any such dependencies should be statically linked to the binary.
To boot a docker container running the cflinuxfs2 filesystem:
docker run -it cloudfoundry/cflinuxfs2 bashTo boot a docker container running the lucid64 filesystem:
docker run -it cloudfoundry/lucid64 bashTo compile the above Go application on the rootfs, golang must be installed. apt-get install golang and go build app.go will produce an app binary.
When deploying your binary to Cloud Foundry, you can specify the root filesystem it should run against with cf push's -s option flag:
cf push my_app -s (cflinuxfs2|lucid64)To run docker on Mac OS X, we recommend boot2docker.
Find our guidelines here.
To report an issue with the buildpack, open an issue on this GitHub repo.