all: run # This makefile contains some convenience commands for deploying and publishing. # For example, to build and run the docker container locally, just run: # $ make # or to publish the :latest version to the specified registry as :1.0.0, run: # $ make publish version=1.0.0 name = ecs-refarch-cloudformation/website-service registry = 275396840892.dkr.ecr.us-east-1.amazonaws.com version ?= latest binary: $(call blue, "Building Linux binary ready for containerisation...") docker run --rm -it -v "${GOPATH}":/gopath -v "$(CURDIR)":/app -e "GOPATH=/gopath" -w /app golang:1.7 sh -c 'CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o app' image: binary $(call blue, "Building docker image...") docker build -t ${name}:${version} . $(MAKE) clean run: image $(call blue, "Running Docker image locally...") docker run -i -t --rm -p 8000:8000 ${name}:${version} publish: $(call blue, "Publishing Docker image to registry...") docker tag ${name}:latest ${registry}/${name}:${version} docker push ${registry}/${name}:${version} clean: @rm -f app define blue @tput setaf 6 @echo $1 @tput sgr0 endef