-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
110 lines (85 loc) · 3.41 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#)####################################################################################
# _____ _ _ _ _ _____ _ #
# / ____| | | | | | | | | __ \ | | #
# | (___ | |__ __ _| |_| |_ ___ _ __ ___ __| | | |__) |___ __ _| |_ __ ___ ___ #
# \___ \| '_ \ / _` | __| __/ _ \ '__/ _ \/ _` | | _ // _ \/ _` | | '_ ` _ \/ __|#
# ____) | | | | (_| | |_| || __/ | | __/ (_| | | | \ \ __/ (_| | | | | | | \__ \#
# |_____/|_| |_|\__,_|\__|\__\___|_| \___|\__,_| |_| \_\___|\__,_|_|_| |_| |_|___/#
#####################################################################################
#
# Makefile for building, running, and testing
#
APP_NAME = frontend
# Import dotenv
ifneq (,$(wildcard ../.env))
include ../.env
export
endif
# Application versions
BASE_VERSION = $(shell git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//')
COMMIT_HASH = $(shell git rev-parse --short HEAD)
# Gets the directory containing the Makefile
ROOT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Base container registry
SRO_BASE_REGISTRY ?= docker.io
SRO_REGISTRY ?= $(SRO_BASE_REGISTRY)/sro
# The registry for this service
REGISTRY = $(SRO_REGISTRY)/$(APP_NAME)
time=$(shell date +%s)
# Protos
PROTOS_DIR = "$(ROOT_DIR)/api"
PROTO_OUT_DIR="$(ROOT_DIR)/src/protos"
PROTOS = $(shell find "$(PROTOS_DIR)" -name "*.proto")
# Versioning
VERSION=$(BASE_VERSION)
ifeq ($(VERSION),)
VERSION := 0.0.0
endif
VERSION_PARTS=$(subst ., ,$(VERSION))
MAJOR_VERSION=$(word 1,$(VERSION_PARTS))
MINOR_VERSION=$(word 2,$(VERSION_PARTS))
PATCH_VERSION=$(word 3,$(VERSION_PARTS))
deploy: aws-docker-login push
docker:
docker build --build-arg APP_VERSION=$(BASE_VERSION) -t sro-$(APP_NAME) -f Dockerfile .
aws-docker-login:
aws ecr get-login-password | docker login --username AWS --password-stdin $(SRO_BASE_REGISTRY)
push:
docker tag sro-$(APP_NAME) $(SRO_REGISTRY)/$(APP_NAME):latest
docker tag sro-$(APP_NAME) $(SRO_REGISTRY)/$(APP_NAME):$(BASE_VERSION)
docker tag sro-$(APP_NAME) $(SRO_REGISTRY)/$(APP_NAME):$(BASE_VERSION)-$(COMMIT_HASH)
docker push $(SRO_REGISTRY)/$(APP_NAME):latest
docker push $(SRO_REGISTRY)/$(APP_NAME):$(BASE_VERSION)
docker push $(SRO_REGISTRY)/$(APP_NAME):$(BASE_VERSION)-$(COMMIT_HASH)
docker-push: docker push
.PHONY: clean-protos protos $(PROTOS)
clean-protos:
rm -rf "$(PROTO_OUT_DIR)"
mkdir -p "$(PROTO_OUT_DIR)"
git submodule update --remote --merge
protos: clean-protos $(PROTOS)
$(PROTOS):
protoc "$@" \
-I $(PROTOS_DIR) \
--plugin=protoc-gen-ts=$(ROOT_DIR)/node_modules/.bin/protoc-gen-ts \
--ts_opt=long_type_number \
--ts_out=$(PROTO_OUT_DIR)
# --plugin=protoc-gen-grpc-web=$(ROOT_DIR)/node_modules/.bin/protoc-gen-grpc-web \
# --grpc-web_out=import_style=typescript,mode=grpcweb:$(PROTO_DIR) \
# --plugin=protoc-gen-js=$(ROOT_DIR)/node_modules/.bin/protoc-gen-js \
# --js_out="import_style=commonjs,binary:$(PROTO_DIR)"
# --plugin=protoc-gen-ts=$(ROOT_DIR)/node_modules/.bin/protoc-gen-ts \
# --ts_out="service=grpc-web:$(PROTO_DIR)"
git: git-patch
git-major:
git tag v$(shell echo $(MAJOR_VERSION)+1 | bc).0.0
git push
git push --tags
git-minor:
git tag v$(MAJOR_VERSION).$(shell echo $(MINOR_VERSION)+1 | bc).0
git push
git push --tags
git-patch:
git tag v$(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $(PATCH_VERSION)+1 | bc)
git push
git push --tags