-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathMakefile
executable file
·57 lines (44 loc) · 1.21 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
BASE_IMAGE_TAG = 3.9
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/$(IMAGE_REPO_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
# Normalize branch name for Docker tag compatibility
BRANCH_NAME_SAFE = $(subst /,-,$(BRANCH_NAME))
$(info BRANCH_NAME_SAFE="$(BRANCH_NAME_SAFE)")
# git release version - use for rollbacks
TAG ?= $(BASE_IMAGE_TAG)-$(BRANCH_NAME_SAFE)-$(HEAD_VER)
.PHONY: build push
build:
docker build -t $(REPO):$(TAG) \
-f Dockerfile \
--build-arg NGINX_LISTEN_OPTS=$(NGINX_LISTEN_OPTS) \
./
push:
docker push $(REPO):$(TAG)
## up : Start up containers.
up:
@echo "Starting up containers..."
docker-compose pull
docker-compose -f docker-compose.local.yml up -d --build --remove-orphans
## stop : Stop containers.
stop:
@echo "Stopping containers..."
@docker-compose stop