forked from aws-samples/ecs-refarch-cloudformation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (30 loc) · 1.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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/product-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 8001:8001 ${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