-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (53 loc) · 1.56 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
# This Makefile automates possible operations of this project.
#
# Images and description on Docker Hub will be automatically rebuilt on
# pushes to `master` branch of this repo.
#
# It's still possible to build, tag and push images manually. Just use:
# make release
IMAGE_NAME := stefanso/lftp
VERSION ?= latest
TAGS ?= latest
comma := ,
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
# Build Docker image.
#
# Usage:
# make image [VERSION=<image-version>]
# [no-cache=(no|yes)]
image:
docker build --network=host --force-rm \
$(if $(call eq,$(no-cache),yes),--no-cache --pull,) \
-t $(IMAGE_NAME):$(VERSION) .
# Tag Docker image with given tags.
#
# Usage:
# make tags [VERSION=<image-version>]
# [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
tags:
$(foreach tag,$(subst $(comma), ,$(TAGS)),\
$(call tags.do,$(VERSION),$(tag)))
define tags.do
$(eval from := $(strip $(1)))
$(eval to := $(strip $(2)))
docker tag $(IMAGE_NAME):$(from) $(IMAGE_NAME):$(to)
endef
# Manually push Docker images to Docker Hub.
#
# Usage:
# make push [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
push:
$(foreach tag,$(subst $(comma), ,$(TAGS)),\
$(call push.do,$(tag)))
define push.do
$(eval tag := $(strip $(1)))
docker push $(IMAGE_NAME):$(tag)
endef
# Make manual release of Docker images to Docker Hub.
#
# Usage:
# make release [VERSION=<image-version>] [no-cache=(no|yes)]
# [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
release: | image tags push
.PHONY: image tags push release