-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (35 loc) · 1.48 KB
/
Makefile
File metadata and controls
47 lines (35 loc) · 1.48 KB
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
41
42
43
44
45
46
47
include .env.deploy
export
AWS_DEFAULT_PROFILE=${env}-string
ECR=${${env}_AWS_ACCT}.dkr.ecr.us-west-2.amazonaws.com
TAG=${tag}
SERVICE=api
CLUSTER=core
REPO=${ECR}/${SERVICE}
SANDBOX_CLUSTER=sandbox-core
SANDBOX_REPO=${ECR}/sandbox-${SERVICE}
all: build push deploy
all-sandbox: build-sandbox push-sandbox deploy-sandbox
test:
direnv exec . go test -run $(TEST_FUNCTION) $(TEST_PATH) -v
test-envvars:
@[ "${env}" ] || ( echo "env var is not set"; exit 1 )
@[ "${tag}" ] || ( echo "env tag is not set"; exit 1 )
build: test-envvars
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./cmd/app/main ./cmd/app/main.go
docker build --platform linux/amd64 -t $(REPO):${TAG} cmd/app/
rm cmd/app/main
push: test-envvars
aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin $(ECR)
docker push $(REPO):${TAG}
deploy: test-envvars
aws ecs --region $(AWS_REGION) update-service --cluster $(CLUSTER) --service ${SERVICE} --force-new-deployment
build-sandbox: test-envvars
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./cmd/app/main ./cmd/app/main.go
docker build --platform linux/amd64 -t $(SANDBOX_REPO):${TAG} cmd/app/
rm cmd/app/main
push-sandbox: test-envvars
aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin $(ECR)
docker push $(SANDBOX_REPO):${TAG}
deploy-sandbox: test-envvars
aws ecs --region $(AWS_REGION) update-service --cluster $(SANDBOX_CLUSTER) --service ${SERVICE} --force-new-deployment