GithubHelp home page GithubHelp logo

eslizn / openshift-go-cart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smarterclayton/openshift-go-cart

1.0 2.0 0.0 45 KB

Go cartridge for OpenShift Origin

License: Other

Shell 95.31% Go 4.69%

openshift-go-cart's Introduction

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 OPENSHIFT_GO_IP and OPENSHIFT_GO_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.

To provide your own custom GOPATH directory, add a ".gopath" file to the root of your Git repo with the desired GOPATH location, relative to the $OPENSHIFT_HOMEDIR directory. Example of a .gopath file content: app-root/data/mygopath. The specified location will be additive to the existing GOPATH provided by the cartridge as the first path declared in GOPATH (notice the GOPATH spec defines that "Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list").

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, $OPENSHIFT_GO_IP and $OPENSHIFT_GO_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.

openshift-go-cart's People

Contributors

bparees avatar eslizn avatar fabianofranz avatar kechap avatar marcusaram avatar mignev avatar smarterclayton avatar smerrill avatar vbatts avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.