-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.docker
More file actions
49 lines (43 loc) · 1.13 KB
/
Makefile.docker
File metadata and controls
49 lines (43 loc) · 1.13 KB
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
DIRS += $(shell find */* -maxdepth 0 -name Makefile -exec dirname "{}" \;)
.PHONY: build
build: check-go-mod
DOCKER_BUILDKIT=1 \
docker build \
--pull \
--no-cache \
--rm=true \
--platform=linux/amd64 \
--build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \
--build-arg BRANCH=$(BRANCH) \
--build-arg BUILD_GIT_VERSION=$$(git describe --tags --always --dirty) \
--build-arg BUILD_GIT_COMMIT=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +%Y-%m-%dT%H:%M:%SZ) \
-t $(DOCKER_REGISTRY)/$(SERVICE):$(BRANCH) \
-f Dockerfile .
.PHONY: check-go-mod
check-go-mod:
@if [ -f "go.mod" ]; then \
echo "go.mod found, running go mod vendor..."; \
go mod vendor; \
else \
echo "go.mod not found, skipping go mod vendor."; \
fi
.PHONY: upload
upload:
docker push $(DOCKER_REGISTRY)/$(SERVICE):$(BRANCH)
.PHONY: clean
clean:
docker rmi $(DOCKER_REGISTRY)/$(SERVICE):$(BRANCH) || true
docker image prune -f || true
docker builder prune --all -f || true
rm -rf vendor
.PHONY: apply
apply:
@for i in $(DIRS); do \
cd $$i; \
echo "apply $${i}"; \
make apply; \
cd ..; \
done
.PHONY: buca
buca: build upload clean apply