Coder Social home page Coder Social logo

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 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.

openshift-go-cart's People

Contributors

vbatts avatar smarterclayton avatar bparees avatar smerrill avatar

Watchers

 avatar  avatar

Forkers

bparees

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.