A little rant about Make, was created in April 1976 and was implemented using C, first used on Unix and the
file format is Makefile, I find make and Makefiles to complement my build flow using Golang, Docker and
various other projects, it is really nice to have a directory layout with a Makefile, where you know exactly
how and what is needed to build the project.
These last years I've spent coding Golang and preferred tool to orchestrate build and deploy is make.
My Makefiles normally start with variables in the beginning, setting the SHELL, various
environmental variables and then we begin to flesh out the targets and dependencies.
I've come to the conclusion on the preferred way to compile and dockerize using Makefiles, and below I will
show a simple skeleton
SHELL ?= /bin/sh
GIT_COMMIT = $(shell git rev-list HEAD -1)
## BELOW TARGETS TO BE RUN
go build \
-ldflags "-X main.CommitID=$(GIT_COMMIT)" \
-o $@ }
strip -s filename_x64
pack: build strip
upx -q filename_x64
rm -rf filename_x64
@docker build \
-t $(TAG) \
-t $(TAG):$(RELEASE) \
@docker push -t $(TAG)
Another tool of trade is the Gitlab CI/CD, I'm very happy with, below you will see an example of a
.gitlab-ci.yml project file.
These two snippets are useful, but it is up to viewers discretion to understand what is happening and also
why didn't we have a make test target? I think it is up to you how to best test the application, and nothing
another can impose on you or your project.
- make test