-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
executable file
·50 lines (37 loc) · 981 Bytes
/
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
41
42
43
44
45
46
47
48
49
50
-include env_make
# BASE_IMAGE_TAG ?= 3-alpine
BASE_IMAGE_TAG ?= 3
PROJECT_NAME=tap-api
ifdef AWS_ACCOUNT_ID
REGISTRY-IDS=$(AWS_ACCOUNT_ID)
else
$(error AWS_ACCOUNT_ID is not set)
endif
REPO = $(REGISTRY-IDS).dkr.ecr.us-west-2.amazonaws.com/nrel-$(PROJECT_NAME)
ifdef RELEASE_SHA2
HEAD_VER=$(RELEASE_SHA2)
else ifdef RELEASE_SHA1
HEAD_VER=$(RELEASE_SHA1)
else
HEAD_VER=$(shell git log -1 --pretty=tformat:%h)
endif
$(info HEAD_VER="$(HEAD_VER)")
ifdef BRANCH_NAME2
BRANCH_NAME=$(BRANCH_NAME2)
else ifdef BRANCH_NAME1
BRANCH_NAME=$(BRANCH_NAME1)
else
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
endif
$(info BRANCH_NAME="$(BRANCH_NAME)")
# git release version - use for rollbacks
TAG ?= $(BASE_IMAGE_TAG)-$(BRANCH_NAME)-$(HEAD_VER)
.PHONY: build push
build:
docker build -t $(REPO):$(TAG) \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg AWS_ACCOUNT_ID=$(REGISTRY-IDS) \
-f Dockerfile \
./
push:
docker push $(REPO):$(TAG)