Giter Site home page Giter Site logo

ocp-go-api's Introduction

ocp-go-api

A very simple stateless HTTP API written in Go


Install Go (from linux CLI)

Set the Go Version

  • export VERSION=1.18.3

Download the Go archive.

  • curl -O https://dl.google.com/go/go$VERSION.linux-amd64.tar.gz

Verify the SHA256 Checksum (against the downloads page).

  • sha256sum go$VERSION.linux-amd64.tar.gz

Extract the tarball into the /usr/local directory.

  • tar -C /usr/local -xzf go$VERSION.linux-amd64.tar.gz

Add the Go binaries to your $PATH.

  • export PATH=$PATH:/usr/local/go/bin
  • To persist this across bash sessions, add to ~/.bashrc

Test Go Install worked

  • go version

Build, Run and Test

Build the App

  • go build cmd/hello/hello.go

Run the App (from a terminal)

  • ./hello

Test the App (from a different terminal) - Note the Hostname / Machine Name

  • curl localhost:8180
  • curl localhost:8180/test
  • curl localhost:8180/anyurihere/1/2/3/4

Build and upload a Container Image to public Container Registry

Build Image

  • nerdctl build -t <image-name> .
  • e.g. - nerdctl build -t tonydawson1000/ocp-go-api .

Verify (List) Image

  • nerdctl images

Run a Local Container Instance

  • nerdctl run --name hello-go --rm -p 8180:8180 <image-name>
  • e.g. - nerdctl run --name hello-go --rm -p 8180:8180 tonydawson1000/ocp-go-api

Test the App (from a different terminal) - Note the Hostname / ContainerId

  • curl localhost:8180
  • curl localhost:8180/test
  • curl localhost:8180/anyurihere/1/2/3/4

Push to public Container Registry (Docker Hub)

  • Login (Default Docker Hub)
    • nerdctl login
  • Push
    • nerdctl push <image-name>:<tag>
    • e.g. - nerdctl push tonydawson1000/ocp-go-api:latest

ocp-go-api's People

Contributors

tonydawson1000 avatar

Watchers

 avatar

Forkers

mdbeasley

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.