This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (47 loc) · 2.16 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
cnf ?= .env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
VERSION ?= $(shell cat .version)
IMAGE_NAME = anvil
IMAGE_ORG = indemnity83
PORT = 8080
VOLUME = `pwd`/storage
# HELP
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
# DOCKER TASKS
# Build the container
build: ## Build the container
docker build --build-arg VERSION=$(VERSION) -t $(IMAGE_NAME) .
build-nc: ## Build the container without caching
docker build --build-arg VERSION=$(VERSION) --no-cache -t $(IMAGE_NAME) .
run: ## Run container on port configured in `.env`
docker run -it --rm --env-file .env -v $(VOLUME):/storage -p $(PORT):8080 --name "$(IMAGE_NAME)" $(IMAGE_NAME)
up: build run ## Build the container then run it
clean: stop ## Stop any running containers and remove the image
docker rm $(IMAGE_NAME); docker rmi $(IMAGE_NAME)
stop: ## Stop a running container
docker stop $(IMAGE_NAME)
release: build-nc publish ## Make a release by building and publishing the `{version}` and `latest` tagged containers to Dockerhub
# Docker publish
publish: publish-latest publish-version ## Publish the `{version}` and `latest` tagged containers to Dockerhub'
publish-latest: tag-latest ## Publish the `latest` taged container to Dockerhub'
@echo 'publish latest to $(IMAGE_ORG)'
docker push $(IMAGE_ORG)/$(IMAGE_NAME):latest
publish-version: tag-version ## Publish the `{version}` taged container to Dockerhub'
@echo 'publish $(VERSION) to $(IMAGE_ORG)'
docker push $(IMAGE_ORG)/$(IMAGE_NAME):$(VERSION)
# Docker tagging
tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags
tag-latest: build ## Generate container `latest` tag
@echo 'create tag latest'
docker tag $(IMAGE_NAME) $(IMAGE_ORG)/$(IMAGE_NAME):latest
tag-version: build ## Generate container `{version}` tag
@echo 'create tag $(VERSION)'
docker tag $(IMAGE_NAME) $(IMAGE_ORG)/$(IMAGE_NAME):$(VERSION)
version: ## Output the current version
@echo $(VERSION)