-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·43 lines (34 loc) · 1.18 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
SHELL := /bin/bash
# Global stuff
DOCKER=docker
CONFIG="makefile.json"
# changelog
SOURCE_PATH := $(shell pwd)
WORKING_PATH="/opt"
# jq
JQ_CONTAINER=imega/jq
JQ=$(DOCKER) run -i $(JQ_CONTAINER) -c -r
# Items from $(CONFIG)
ECR_URI := $(shell cat $(CONFIG) | $(JQ) .aws.ecr.uri)
ECR_REGION := $(shell cat $(CONFIG) | $(JQ) .aws.ecr.region)
AWS_ACCOUNT_ID := $(shell cat $(CONFIG) | $(JQ) .aws.account_id)
IMAGE_NAME := $(shell cat $(CONFIG) | $(JQ) .docker.image_name)
# AWS
AWS_CONTAINER=amazon/aws-cli
AWS_WORKING_PATH=/aws
AWS=$(DOCKER) run -e AWS_SECRET_ACCESS_KEY=$$AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=$$AWS_ACCESS_KEY_ID $(AWS_CONTAINER)
.PHONY: init
init:
export DOCKER_PASSWORD=`$(AWS) ecr-public get-login-password --region $(ECR_REGION)` ; \
$(DOCKER) login --username AWS -p $$DOCKER_PASSWORD $(ECR_URI)
.PHONY: build
build:
$(DOCKER) build . -t $(IMAGE_NAME):$(version)
.PHONY: release
release:
$(DOCKER) tag $(IMAGE_NAME):$(version) $(ECR_URI)/$(IMAGE_NAME):$(version)
$(DOCKER) tag $(IMAGE_NAME):$(version) $(ECR_URI)/$(IMAGE_NAME):latest
$(DOCKER) push $(ECR_URI)/$(IMAGE_NAME):$(version)
$(DOCKER) push $(ECR_URI)/$(IMAGE_NAME):latest
.PHONY: all
all: init build release