-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
65 lines (52 loc) · 2 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
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
IMAGE_NAME=ploneorgbr/portal-padrao
# Current version
IMAGE_TAG=`python helpers/version.py`
NIGHTLY_IMAGE_TAG=nightly
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
.PHONY: all
all: build-images
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
image-tag: # Print current version
@echo "$(IMAGE_TAG)"
current-version: # Print current version
@echo "Current version: $(IMAGE_TAG)"
create-tag: # Create a new tag using git
@echo "Creating new tag $(IMAGE_TAG)"
if git show-ref --tags v$(IMAGE_TAG) --quiet; then echo "$(IMAGE_TAG) already exists";else git tag -a v$(IMAGE_TAG) -m "Release $(IMAGE_TAG)" && git push && git push --tags;fi
commit-release: # Commit new version change and create tag
@echo "Commiting changes"
@git commit -am "Portal Padrão versão $(IMAGE_TAG)"
make create-tag
.PHONY: build-image
build-image: ## Build Docker Image
@echo "Building $(IMAGE_NAME):$(IMAGE_TAG)"
@docker build . -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile
.PHONY: push-image
push-image: ## Push docker image to dockerhub
@echo "Push $(IMAGE_NAME):$(IMAGE_TAG) to Docker Hub"
@docker push $(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: release
release: build-image push-image ## Build and push the image to docker hub
@echo "Released $(IMAGE_NAME):$(IMAGE_TAG)"
.PHONY: run-image
run-image: build-image ## Run local image
@echo "Running $(IMAGE_NAME):$(IMAGE_TAG)"
@docker run --rm -p 8080:8080 $(IMAGE_NAME):$(IMAGE_TAG)