*** THE DEPLOY IS UNDER CONSTRUCTION - CHECK BACK SOON ***
Deploy a "hello-world" docker image to Microsoft Azure VM.
Other Services
- PaaS
- CaaS
- IaaS
Table of Contents
- ???
Documentation and Reference
- The hello-go-deploy-azure-vm docker image on DockerHub
- This repos github webpage built with concourse
For this exercise I used go. Feel free to use a language of your choice,
To build a docker image you will need docker on your machine,
To push a docker image you will need,
To deploy to microsoft azure vm
you will need,
As a bonus, you can use Concourse CI to run the scripts,
- concourse (Optional)
This repo may have a few examples. We will deploy example 1.
To run from the command line,
go run main.go
Every 2 seconds hello-go-deploy-azure-vm
will print:
Hello everyone, count is: 1 Hello everyone, count is: 2 Hello everyone, count is: 3 etc...
Lets unit test the code,
go test -cover ./... | tee /test/test_coverage.txt
There is a unit-tests.sh
script to run the unit tests. There is also a script in the /ci folder to run the unit tests in concourse.
We will be using a multi-stage build using a Dockerfile. The end result will be a very small docker image around 13MB.
docker build -f build-push/Dockerfile -t jeffdecola/hello-go-deploy-azure-vm .
Obviously, replace jeffdecola
with your DockerHub username.
In stage 1, rather than copy a binary into a docker image (because that can cause issue), the Dockerfile will build the binary in the docker image.
If you open the DockerFile you can see it will get the dependencies and build the binary in go,
FROM golang:alpine AS builder RUN go get -d -v RUN go build -o /go/bin/hello-go-deploy-azure-vm main.go
In stage 2, the Dockerfile will copy the binary created in stage 1 and place into a smaller docker base image based on alpine
, which is around 13MB.
You can check and test your docker image,
docker run --name hello-go-deploy-azure-vm -dit jeffdecola/hello-go-deploy-azure-vm docker exec -i -t hello-go-deploy-azure-vm /bin/bash docker logs hello-go-deploy-azure-vm docker images jeffdecola/hello-go-deploy-azure-vm:latest
There is a build-push.sh
script to build and push to DockerHub. There is also a script in the /ci folder to build and push in concourse.
Lets push your docker image to DockerHub.
If you are not logged in, you need to login to dockerhub,
docker login
Once logged in you can push to DockerHub
docker push jeffdecola/hello-go-deploy-azure-vm
Check you image at DockerHub. My image is located https://hub.docker.com/r/jeffdecola/hello-go-deploy-azure-vm.
There is a build-push.sh
script to build and push to DockerHub. There is also a script in the /ci folder to build and push in concourse.
tbd
For fun, I use concourse to automate the above steps.
A pipeline file pipeline.yml shows the entire ci flow. Visually, it looks like,
The jobs
and tasks
are,
job-readme-github-pages
runs task readme-github-pages.sh.job-unit-tests
runs task unit-tests.sh.job-build-push
runs task build-push.sh.job-deploy
runs task deploy.sh.
The concourse resources type
are,
hello-go-deploy-azure-vm
uses a resource type docker-image to PULL a repo from github.resource-dump-to-dockerhub
uses a resource type docker-image to PUSH a docker image to dockerhub.resource-marathon
users a resource type docker-image to DEPLOY the newly created docker image to marathon.resource-slack-alert
uses a resource type docker image that will notify slack on your progress.resource-repo-status
uses a resource type docker image that will update your git status for that particular commit.
For more information on using concourse for continuous integration, refer to my cheat sheet on concourse.