An example of CI/CD with a simple go application utilizing a multistage docker build.
# creates a new image
$ make build
# runs the image
$ make run
# installs deps etc
$ make install
# execute binary
$ ./bin/cmd
# defaults to "8080"
PORT=3000
# defaults to "Gopher"
NAME="Edgar Allan Poe"
# forces tests to fail
FAILED=true
Run make help
to list available commands:
$ make help
Choose a command run in autoapp:
install Install missing dependencies. Builds binary in ./bin
build Creates a docker image of the app
fail Forces a failed docker build of the app due to failing tests
run Runs the current docker image on port 8080
clean Clean build files. Runs `go clean` internally
fmt Runs gofmt on all source files
test Runs all the tests.
coverage Tests code coverage
missing Displays lines of code missing from coverage
This tutorial assumes you have access to the Google Cloud Platform. While GCP is used for basic infrastructure requirements, the lessons learned in this tutorial can be applied to other platforms.
It's not a requirement. But reading through this tutorial will be easier and available offline utilizing vmd. It requires node.js installed which you can do with
$ brew install node
and then$ npm install -g vmd
. Then in the root of the project$ cd ~/<WORK_DIR>/autoapp/ && vmd
.
Section | Description |
---|---|
Prerequisites | Preface, disclaimers and setting expectations |
Installing the Client Tools | Setup and install of CLIs required |
Creating A New Cluster | Creating and connecting to a GCP GKE cluster |
Deploying Spinnaker | Deploying Spinnaker to our cluster |
Setting up Quay | Step by step configuration for Quay's hooks |
Setting up Spinnaker | Step by step configuration for spinnaker to automate deployments |
Setting up Drone | Wire up a simple CI pre-merge check |
Deploying 🚀 | Submitting a pull-request which on successful merge will trigger our CI/CD |