This repository has been archived by the owner on Jan 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
62 lines (48 loc) · 2.31 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
DOCKER_REPO := klutchell/unbound
TAG := 1.9.6
AUTHORS := Kyle Harding <https://klutchell.dev>
SOURCE_URL := https://github.com/$(DOCKER_REPO)
DESCRIPTION := Unbound is a validating, recursive, caching DNS resolver
BUILD_DATE := $(strip $(shell docker run --rm busybox date -u +'%Y-%m-%dT%H:%M:%SZ'))
BUILD_VERSION := $(TAG)
VCS_REF := $(strip $(shell git describe --tags --always --dirty))
DOCKER_CLI_EXPERIMENTAL := enabled
BUILDX_INSTANCE_NAME := $(subst /,-,$(DOCKER_REPO))
BUILD_OPTS := \
--label "org.opencontainers.image.created=$(BUILD_DATE)" \
--label "org.opencontainers.image.authors=$(AUTHORS)" \
--label "org.opencontainers.image.url=$(SOURCE_URL)" \
--label "org.opencontainers.image.documentation=$(SOURCE_URL)" \
--label "org.opencontainers.image.source=$(SOURCE_URL)" \
--label "org.opencontainers.image.version=$(BUILD_VERSION)" \
--label "org.opencontainers.image.revision=$(VCS_REF)" \
--label "org.opencontainers.image.title=$(DOCKER_REPO)" \
--label "org.opencontainers.image.description=$(DESCRIPTION)" \
--tag $(DOCKER_REPO):$(TAG) \
--tag $(DOCKER_REPO):latest \
$(EXTRA_OPTS)
COMPOSE_PROJECT_NAME := $(subst /,-,$(DOCKER_REPO))
COMPOSE_FILE := test/docker-compose.yml
COMPOSE_OPTIONS := -e COMPOSE_PROJECT_NAME -e COMPOSE_FILE -e DOCKER_REPO
.EXPORT_ALL_VARIABLES:
.DEFAULT_GOAL := all
.PHONY: all build buildx test clean binfmt help
all: build test ## build and test a local image
build: ## build and label a local image
docker build . $(BUILD_OPTS)
buildx: binfmt ## cross-build on supported platforms with buildx
-docker buildx create --use --name $(BUILDX_INSTANCE_NAME)
-docker buildx inspect --bootstrap
docker buildx build . $(BUILD_OPTS)
test: binfmt ## run a simple image test with docker-compose
docker-compose up --force-recreate --abort-on-container-exit
docker-compose down
clean: ## clean dangling images, containers, and build instances
-docker-compose down
-docker buildx rm $(BUILDX_INSTANCE_NAME)
-docker image prune --all --force --filter "label=org.opencontainers.image.title=$(DOCKER_REPO)"
binfmt:
docker run --rm --privileged aptman/qus -s -- -r
docker run --rm --privileged aptman/qus -s -- -p
help: ## display available commands
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'