-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.docker
42 lines (37 loc) · 1.84 KB
/
Makefile.docker
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
# Makefile.docker contains the shared tasks for building, tagging and pushing Docker images.
# This file is included into the Makefile files which contain the Dockerfile files (E.g.
# kafka-base, kafka etc.).
#
# The DOCKER_ORG (default is name of the current user) and DOCKER_TAG (based on Git Tag,
# default latest) variables are used to name the Docker image. DOCKER_REGISTRY identifies
# the registry where the image will be pushed (default is Docker Hub).
DOCKERFILE_DIR ?= ./
DOCKER_REGISTRY ?= docker.io
DOCKER_ORG ?= $(USER)
DOCKER_TAG ?= latest
BUILD_TAG ?= latest
.PHONY: docker_build
docker_build:
# Build Docker image ...
docker $(DOCKER_BUILDX) build $(DOCKER_BUILD_ARGS) -t termination-monitor/$(PROJECT_NAME):latest $(DOCKERFILE_DIR)
# The Dockerfiles all use FROM ...:latest, so it is necessary to tag images with latest (-t above)
# But because we generate Kafka images for different versions we also need to tag with something
# including the kafka version number. This BUILD_TAG is used by the docker_tag target.
# Also tag with $(BUILD_TAG)
docker tag termination-monitor/$(PROJECT_NAME):latest termination-monitor/$(PROJECT_NAME):$(BUILD_TAG)
.PHONY: docker_save
docker_save:
# Saves the container as TGZ file
docker save termination-monitor/$(PROJECT_NAME):$(BUILD_TAG) | gzip > termination-monitor.tar.gz
.PHONY: docker_load
docker_load:
# Loads the container as TGZ file
docker load < termination-monitor.tar.gz
.PHONY: docker_tag
docker_tag:
# Tag the $(BUILD_TAG) image we built with the given $(DOCKER_TAG) tag
docker tag termination-monitor/$(PROJECT_NAME):$(BUILD_TAG) $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG)
.PHONY: docker_push
docker_push: docker_tag
# Push the $(DOCKER_TAG)-tagged image to the registry
docker push $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG)