-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (28 loc) · 996 Bytes
/
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
.PHONY: help default build push test clean
NAME ?= aaneci/debug
REGISTRY ?= docker.io
COMMIT ?= $(shell git rev-parse --short HEAD)
default: help
help: ## Print this help text
@printf "\n"
@awk 'BEGIN {FS = ":.*?## "}; ($$2 && !/@awk/){printf "${CYAN}%-30s${NC} %s\n", $$1, $$2}' $(lastword ${MAKEFILE_LIST}) | sort
@printf "\n"
# BUILD & PUSH
# -----------
build: ## Builds the local Docker container for development
docker build -t ${NAME}:$(COMMIT) .
docker tag ${NAME}:$(COMMIT) ${NAME}:latest
push: build ## Push Docker image to $(REGISTRY)
docker tag ${NAME}:$(COMMIT) $(REGISTRY)/${NAME}:$(COMMIT)
docker push $(REGISTRY)/${NAME}:$(COMMIT)
docker tag ${NAME}:latest $(REGISTRY)/${NAME}:latest
docker push $(REGISTRY)/${NAME}:latest
# TEST
# -----------
test: build ## Run docker image locally
docker run -it --rm --name debug_container ${NAME}:latest bash
# CLEANUP
# -----------
clean:
docker rm -f debug_container
docker rmi --force ${NAME}:$(COMMIT) ${NAME}:latest