Skip to content

JeffDeCola/hello-go-deploy-marathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HELLO GO DEPLOY MARATHON

Tag Latest Go Reference Go Report Card codeclimate Maintainability codeclimate Issue Count Docker Pulls MIT License jeffdecola.com

Deploy a "hello-world" docker image to mesos/marathon.

Other Services

Table of Contents

Documentation and Reference

OVERVIEW

Every 2 seconds this App will print,

    INFO[0000] Let's Start this!
    Hello everyone, count is: 1
    Hello everyone, count is: 2
    Hello everyone, count is: 3
    etc...

PREREQUISITES

You will need the following go packages,

go get -u -v github.com/sirupsen/logrus
go get -u -v github.com/cweill/gotests/...

SOFTWARE STACK

RUN

To run.sh,

cd hello-go-deploy-marathon-code
go run main.go

To create-binary.sh,

cd hello-go-deploy-marathon-code/bin
go build -o hello-go ../main.go
./hello-go

This binary will not be used during a docker build since it creates it's own.

STEP 1 - TEST

To create unit _test files,

cd hello-go-deploy-marathon-code
gotests -w -all main.go

To run unit-tests.sh,

go test -cover ./... | tee test/test_coverage.txt
cat test/test_coverage.txt

STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)

This docker image is built in two stages. In stage 1, rather than copy a binary into a docker image (because that can cause issues), the Dockerfile will build the binary in the docker image. In stage 2, the Dockerfile will copy this binary and place it into a smaller docker image based on alpine, which is around 13MB.

To build.sh with a Dockerfile,

cd hello-go-deploy-marathon-code/build
docker build -f Dockerfile -t jeffdecola/hello-go-deploy-marathon .

You can check and test this docker image,

docker images jeffdecola/hello-go-deploy-marathon
docker run --name hello-go-deploy-marathon -dit jeffdecola/hello-go-deploy-marathon
docker exec -i -t hello-go-deploy-marathon /bin/bash
docker logs hello-go-deploy-marathon
docker rm -f hello-go-deploy-marathon

STEP 3 - PUSH (TO DOCKERHUB)

You must be logged in to DockerHub,

docker login

To push.sh,

docker push jeffdecola/hello-go-deploy-marathon

Check the hello-go-deploy-marathon docker image at DockerHub.

STEP 4 - DEPLOY (TO MARATHON)

The app.json tells marathon how to deploy the docker image from dockerhub.

To run mesos/marathon in a docker container,

docker run --rm --privileged -p 5050:5050 -p 5051:5051 -p 8080:8080 mesos/mesos-mini:1.9.x
http://localhost:8080
http://192.168.20.122:8080

To deploy.sh,

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

CONTINUOUS INTEGRATION & DEPLOYMENT

Refer to ci-README.md on how I automated the above steps using concourse.