/hello-go

Using Concourse to test, build, push (to DockerHub) and deploy a long running "hello-world" Docker Image to Marathon.

Primary LanguageShellMIT LicenseMIT

hello-go

Code Climate Issue Count Go Report Card GoDoc License

hello-go uses concourse to test, build, push (to DockerHub) and deploy a long running "hello-world" docker image to mesos/marathon.

hello-go Docker Image on DockerHub.

hello-go GitHub Webpage

REQUIREMENTS

You obviously need concourse.

To build you will need,

  • DockerHub account
  • For manual testing, docker running on your machine.

To deploy you will need,

LONG-RUNNING APP FOR MARATHON

Written in go, every 3 seconds hello-go will print:

Hello everyone, count is: 1
Hello everyone, count is: 2
Hello everyone, count is: 3
etc...

RUN SOURCE CODE FROM THE COMMAND LINE

go run main.go

BUILD - DOCKER IMAGE

Create a binary hello-go,

go build -o hello-go main.go

Grab the Dockerfile to put in this directory,

cp ci/Dockerfile .

Build your docker image using Dockerfile,

docker build -t jeffdecola/hello-go .

Obviously, replace jeffdecola with your DockerHub username.

Check your docker images,

docker images

It will be listed as jeffdecola/hello-go

BUILD - PUSH DOCKER IMAGE TO DOCKER HUB

Push to your newly built docker image to DockerHub.

docker login
docker push jeffdecola/hello-go

Check you image at DockerHub. My image is https://hub.docker.com/r/jeffdecola/hello-go.

Once image is is on DockerHub, you can run in interactive mode (-i) so you can ctrl-c to stop.

Erase your local image first to prove it grabs it from dockerhub,

docker rmi jeffdecola/hello-go

Now run it. Docker will grab the image from dockerHub and start a docker container on your machine.

docker run -t -i jeffdecola/hello-go

DEPLOY - APP TO MARATHON

The marathon .json file,

resource-marathon-deploy uses a Marathon .json file (app.json) to deploys the newly created docker image (APP) to Marathon.

The hello-go docker image can now be manually deployed from DockerHub to mesos/marathon by using the command:

curl -X PUT http://10.141.141.10:8080/v2/apps/hello-go-long-running -d @app.json \
-H "Content-type: application/json"

The app.json file will pick the latest image a DockerHub jeffdecola/hello-go:latest.

TESTED, BUILT & PUSHED TO DOCKERHUB USING CONCOURSE

To automate the creation of the hello-go docker image, a concourse pipeline will,

  • Update README.md for hello-go github webpage.
  • Unit Test the code.
  • Build the docker image hello-go and push to DockerHub.
  • Deploy the DockerHub image to mesos/marathon.

IMAGE - hello-go concourse ci pipeline - IMAGE

As seen in the pipeline diagram, the resource-dump-to-dockerhub uses the resource type docker-image to push a docker image to dockerhub.

resource-marathon-deploy deploys the newly created docker image to marathon.

hello-go also contains a few extra concourse resources:

  • A resource (resource-slack-alert) uses a docker image that will notify slack on your progress.
  • A resource (resource-repo-status) use a docker image that will update your git status for that particular commit.
  • A resource (resource-template) that can be used as a starting point and template for creating other concourse ci resources.

For more information on using concourse for continuous integration, refer to my cheat sheet on concourse.