Skip to content

vitalie/openshift-go-cart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenShift Go Cartridge

Runs Go on OpenShift using downloadable cartridge support. To install to OpenShift from the CLI (you'll need version 1.9 or later of rhc), run:

rhc create-app mygo https://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-go-cart

Once the app is created, you'll need to create and add a ".godir" file in your repo to tell the cartridge what the package of your Go code is. A typical .godir file might contain:

github.com/smarterclayton/goexample

which would tell OpenShift to place all of the files in the root of the Git repository inside of the github.com/smarterclayton/goexample package prior to compilation.

When you push code to the repo, the cart will compile your package into $OPENSHIFT_REPO_DIR/bin/, with the last segment of the .godir being the name of the executable. For the above .godir, your executable will be:

$OPENSHIFT_REPO_DIR/bin/goexample

If you want to serve web requests (vs. running in the background), you'll need to listen on the ip address and port that OpenShift allocates - those are available as HOST and PORT in the environment.

The repository contains a sample go file which will print "hello, world" when someone hits your web application - see web.go.

Any log output will be generated to $OPENSHIFT_GO_LOG_DIR

How it Works

When you push code to your repo, a Git postreceive hook runs and invokes the bin/compile script. This attempts to download a Go environment for you into $OPENSHIFT_GO_DIR/cache. Once the environment is setup, the cart runs

go get -tags openshift ./...

on a working copy of your source. The main file that you run will have access to two environment variables, $HOST and $PORT, which contain the internal address you must listen on to receive HTTP requests to your application.

Credits

The bin/compile script is based on the Heroku Go buildpack, adapted for OpenShift cartridges.

About

Go cartridge for OpenShift Origin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 95.3%
  • Go 4.7%