-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (40 loc) · 1.27 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
IMAGE_NAME=nomad
BUILDX_BUILDER_NAME="nomad-buildx-builder"
BUILDX_TARGETPLATFORM="linux/amd64,linux/arm64"
check:
@which docker
test -n "$(NOMAD_VERSION)"
prepare:
make check
$(eval export BUILDX_BUILDER_CHECK=$(shell docker buildx ls | grep $(BUILDX_BUILDER_NAME) | head -n 1 | awk '{print $$1}'))
if [ "$(BUILDX_BUILDER_CHECK)" = "$(BUILDX_BUILDER_NAME)" ]; then \
echo "Docker Buildx Builder Found..."; \
echo $(BUILDX_BUILDER_CHECK); \
else \
echo "Docker Buildx Builder Not Found, Creating..."; \
echo $(BUILDX_BUILDER_CHECK); \
docker buildx create --name $(BUILDX_BUILDER_NAME) --use; \
fi
build:
make prepare
docker buildx build . \
--build-arg NOMAD_VERSION=$(NOMAD_VERSION) \
--platform $(BUILDX_TARGETPLATFORM) \
--tag $(IMAGE_NAME):latest \
--tag $(IMAGE_NAME):$(NOMAD_VERSION) \
-o type=docker
login:
test -n "$(DOCKER_USERNAME)"
test -n "$(DOCKER_PASSWORD)"
docker login --username ${DOCKER_USERNAME} --password ${DOCKER_PASSWORD}
release:
make prepare
make login
docker buildx build . \
--build-arg NOMAD_VERSION=$(NOMAD_VERSION) \
--platform $(BUILDX_TARGETPLATFORM) \
--tag $(DOCKER_USERNAME)/$(IMAGE_NAME):latest \
--tag $(DOCKER_USERNAME)/$(IMAGE_NAME):$(NOMAD_VERSION) \
--push
clean:
docker buildx rm $(BUILDX_BUILDER_NAME)