Code Monkey home page Code Monkey logo

golang-ex's Introduction

Golang Sample App on OpenShift

This is a sample Golang web application for OpenShift v3 that use the beego framework. This sample uses official Docker golang image for the build without any modification to the image or sample itself.

This example was copied from the official beego samples repository.

If you'd like to install it, follow these instructions.

The steps in this document assume that you have access to an OpenShift deployment that you can deploy applications on, including the default set of ImageStreams defined. Instructions for installing the default ImageStreams are available here. If you are defining the set of ImageStreams now, remember to pass in the proper cluster-admin credentials and to create the ImageStreams in the 'openshift' namespace.

Installation

  1. Fork a copy of golang-ex

  2. Clone your repository to your development machine and cd to the repository directory

  3. Add a Golang application from the beego template. Note: You will need to replace part of the SOURCE_REPOSITORY_URL where it says yourusername with your GitHub username before running:

     $ oc new-app openshift/templates/beego.json -p SOURCE_REPOSITORY_URL=https://github.com/yourusername/golang-ex
    
  4. A build will be started automatically. It might take some time.
    You can run the command below to watch for builds:

     $ oc get builds -w
    
  5. Once the build is running, follow the build logs:

     $ oc logs -f bc/beego-example
    
  6. Wait for the beego-example pod to start up (may take some time):

     $ oc get pods -w
    

    Sample output:

     NAME                     READY     REASON       RESTARTS   AGE
     beego-example-1-6c23l     1/1       Running        0          2m
     beego-example-1-build     0/1       ExitCode:0     0          4m
    
  7. Check the IP and port the beego-example service is running on:

     $ oc get svc
    

    Sample output:

     NAME             LABELS                              SELECTOR              IP(S)           PORT(S)
     beego-example     template=beego-example     name=beego-example           172.30.210.29    8080/TCP
    

In this case, the IP for beego-example is 172.30.210.29 and it is on port 8080.
Note: you can also get this information from the web console.

Building

After you create the application from a template, you can follow the build progress with the oc logs command:

$ oc logs -f bc/beego-example

Accessing the application

If you have the OpenShift router running, you should be able to access the application just by typing the beego-example route DNS (beego-example.openshiftapps.com) into your browser. However, you will have to run you own DNS server first, but we can cheat it by modifying the /etc/hosts file on your host machine. Just append this line at the end of that file:

192.168.124.206 beego-example.openshiftapps.com

The 192.168.124.206 represents the IP address of the machine you are running OpenShift on. If your are running OpenShift on a different IP address, simply replace 192.168.124.206 with your OpenShift IP address when adding the line above to your /etc/hosts file. Once you have this change, you can just type the application DNS into browser and you should see the chat application login screen.

License

This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to CC0.

The sample beego application code follows the original Apache License

golang-ex's People

Contributors

0xmichalis avatar bparees avatar coreydaley avatar danielhelfand avatar deads2k avatar gabemontero avatar guangxuli avatar mfojtik avatar rhcarvalho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

golang-ex's Issues

Root access and build strategy

I'm getting this result for 'oc new-app':

  • The image does not expose any ports - if you want to load balance or send traffic to this component you will need to create a service with 'expose dc/ --port=[port]' later
  • WARNING: Image "" runs as the 'root' user which may not be permitted by your cluster administrator
  • error: buildconfigs "" is forbidden: build strategy Docker is not allowed

So when I run 'oc get services' I've got none.

Add documentation for running golang-ex with Minishift

I would like to suggest to add documentation around using golang-ex on Minishift. It is nothing hard, but would save some time for newcomers. The only need for user is to disable pre-set value for APPLICATION_DOMAIN:

oc new-app openshift/templates/beego.json -p SOURCE_REPOSITORY_URL=https://github.com/yourusername/golang-ex -p APPLICATION_DOMAIN=""

Also in Accessing the application should be then mention that in case of Minishift, no other work is needed, the application will be resolved with help of Minishift via nip.io.

I will be happy to work on these docs, if proposal is accepted.

Consider adopting Developer Certificate of Origin (DCO)

Hi,

I'd also suggest adopting the Developer Certificate of Origin [0] created by the Linux Foundation to ensure that contributions are provided under a compatible license. Lawyers seem to be okay with this; many projects use it [1] and Docker uses something similar [2].

On the other hand, the DCO seems to have some problems around patent grants; probably best to ask a lawyer for guidance [3].

Jonathan

[0] http://developercertificate.org/
[1] http://www.do-not-panic.com/2014/02/developer-certificate-of-origin.html
[2] https://blog.docker.com/2014/01/docker-code-contributions-require-developer-certificate-of-origin/
[3] http://blog.hansenpartnership.com/the-dco-patents-and-openstack/

No external dependencies

I propose this example to be a simple app based on net/http without any external dependencies.

If earlier I already doubted why we use a framework, and why beego in particular; now I have a reason to dislike using beego: #9 (comment).

Beego has recently merged PRs that break the public API and even break their own examples:
https://github.com/astaxie/beego/pull/1540
https://github.com/astaxie/beego/pull/1567

There's no clear "winner" in the land of Go Web Frameworks, and many apps, including OpenShift rely on net/http without a web framework.

@bparees @mfojtik @mnagy @php-coder @PI-Victor thoughts?

error when building

trying it the steps as mentionned in the README and i am getting :

$ oc build-logs beego-example-1 -f                                                                                                   [master]
I1021 04:34:02.514436       1 sti.go:74] The value of ALLOWED_UIDS is [1-]
I1021 04:34:02.519865       1 docker.go:228] Pulling image docker.io/library/golang:1.4.2-onbuild
I1021 04:34:48.017951       1 sti.go:96] Creating a new S2I builder with build config: "Builder Image:\t\tdocker.io/library/golang:1.4.2-onbuild\nSource:\t\t\thttps://github.com/chmouel/golang-ex\nOutput Image Tag:\t172.30.132.87:5000/chmouelb/beego-example:latest\nEnvironment:\t\tOPENSHIFT_BUILD_NAMESPACE=chmouelb,OPENSHIFT_BUILD_SOURCE=https://github.com/chmouel/golang-ex,OPENSHIFT_BUILD_NAME=beego-example-1\nIncremental Build:\tdisabled\nRemove Old Build:\tdisabled\nForce Pull:\t\tdisabled\nQuiet:\t\t\tdisabled\nLayered Build:\t\tdisabled\nDocker Endpoint:\tunix:///var/run/docker.sock\n"
I1021 04:34:48.027589       1 docker.go:211] Image docker.io/library/golang:1.4.2-onbuild available locally
F1021 04:34:48.061875       1 builder.go:54] Build error: image "docker.io/library/golang:1.4.2-onbuild" must specify a user that is numeric and within the range of allowed users

Template icon is not shown

Icon name is probably outdated and needs update.

Currently:

"iconClass": "icon-golang"

Probable fix:

"iconClass": "icon-go-gopher"

Consider relicensing under Apache or using SQLite's Public Domain License

Hi,

If possible (e.g. if Red Hat owns the copyright for this code, or if all authors/copyright owners can agree to such a change), I recommend relicensing this code under the Apache Software License, which would be compatible with OpenShift Origin's licensing terms and covers software patent grants.

If you prefer an even more permissive license (I can't blame you - I use Public Domain for some of my own software), then I would suggest using SQLite's Public Domain terms [0]:

The author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this code under copyright law.

This is because CC0 is not intended to be a software license; see [1, 2].

Jonathan

[0] https://www.sqlite.org/copyright.html
[1] https://blog.creativecommons.org/2011/04/15/using-cc0-for-public-domain-software/
[2] https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software

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.