/rest-json-with-go-in-docker

An example project to create a Docker image for a Go application containing a static REST service.

Primary LanguageMakefileApache License 2.0Apache-2.0

JSON static rest example with Go and Docker

Build Status License

An example project to create a Docker image for a Go application containing a static REST service.

Requirements

  • Docker
  • Go 1.15.x (if you want to build it without using docker builder)

Build it

$ make build                        # build native app to ./build folder
            
$ make docker-build                 # build local docker image
$ make docker-push                  # push local docker image to hub.docker.com
$ make docker-all                   # build and push docker image to hub.docker.com
$ make IMAGE_TAG="0.0.1" docker-all # build and push docker image with specific version

$ make clean                        # clean up go and build folder

Run it native

$ make run                                  # start native app 
$ curl http://localhost:8080/api/channels   # call rest service
$ ctrl+c                                    # stop native app

Run it using docker

$ make docker-run                           # start docker image 
$ curl http://localhost:8080/api/channels   # call rest service
$ make docker-stop                          # stop and remove docker app