forked from techprober/nginx-http-flv-module-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
80 lines (64 loc) · 2.37 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
# Makefile
COMPOSE_FILE := build/docker-compose.yml
REGISTRY_USERNAME := techprober
REGISTRY := quay.io
IMAGE_NAME := nginx-http-flv-module
IMAGE_TAG := dev
DOMAIN_NAME := hikariai.net
ENV := prod
VERSION := latest
# Modify tagging mechanism
ifneq ($(VERSION), latest)
export IMAGE_TAG=$(VERSION)
else
export IMAGE_TAG=latest
endif
# List of commands
.PHONY: login
login:
@echo "[INFO] Login to quay.io"
@echo $(QUAY_PASS) | docker login $(REGISTRY) -u $(REGISTRY_USERNAME) --password-stdin
.PHONY: build
build:
@echo "[INFO] Build application image with tag $(IMAGE_TAG)"
@DOCKER_BUILDKIT=1 docker-compose \
-f $(COMPOSE_FILE) \
build
.PHONY: tag
tag:
@echo "[INFO] Tag the local image as quay.io image"
@docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(REGISTRY)/$(REGISTRY_USERNAME):$(IMAGE_TAG)
@docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(REGISTRY)/$(REGISTRY_USERNAME):latest
.PHONY: publish
publish: login build tag
@echo "[INFO] Publish application image with tag $(IMAGE_TAG) to $(REGISTRY)"
@docker push $(IMAGE_NAME):$(IMAGE_TAG) $(REGISTRY)/$(REGISTRY_USERNAME):$(IMAGE_TAG)
@docker push $(IMAGE_NAME):$(IMAGE_TAG) $(REGISTRY)/$(REGISTRY_USERNAME):latest
.PHONY: run
run:
@echo "[INFO] Run application with tag $(IMAGE_TAG) to $(REGISTRY) locally"
@docker-compose up -d
.PHONY: restart
restart:
@echo "[INFO] Restart application with tag $(IMAGE_TAG) to $(REGISTRY) locally"
@docker-compose up -d --force-recreate
.PHONY: help
help:
$(info ${HELP_MESSAGE})
@exit 0
define HELP_MESSAGE
Usage: $ make [TARGETS]
TARGETS
help Show the help menu
login Login to the target registry
build Build the application image
tag Tag the application image with a production tag to be pushed to the target registry
publish Build the application image, tag it with a custom version tag, and push it to the target registry (version required)
run Run the application container locally (VERSION optional)
restart Restart the application container instance (VERSION optional)
EXAMPLE USAGE
build Build the application image and tag it as latest
publish Build the application iamge, tag it as v1.0.1, and push it to the target registry
run Run the application container locally with the latest tag
restart Restart the application container with the latest tag, or a custom VERSION tag
endef