-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
45 lines (37 loc) · 1.79 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
GIT_SHA1 = $(shell git rev-parse --verify HEAD)
IMAGE_TAG = $(shell git describe --tags `git rev-list --tags --max-count=1` 2> /dev/null || echo 'latest' )
ifeq ($(DEV),TRUE)
TAG_SUFFIX = :dev
else
TAG_SUFFIX = :$(IMAGE_TAG)
endif
IMAGE_DIRS = $(wildcard modules/*)
all: conduit $(IMAGE_DIRS)
define build_docker_image
docker build --no-cache -t ghcr.io/conduitplatform/$(1)$(TAG_SUFFIX) $(3)
docker push ghcr.io/conduitplatform/$(1)$(TAG_SUFFIX)
$(eval SKIP_LATEST=$(if $(findstring $(2),alpha beta rc),true,false))
@if [ "$(SKIP_LATEST)" = "false" ] && [ "$(TAG_SUFFIX)" != ":dev" ]; then \
docker tag ghcr.io/conduitplatform/$(1)$(TAG_SUFFIX) conduitplatform/$(1):$(2) ; \
docker tag ghcr.io/conduitplatform/$(1)$(TAG_SUFFIX) ghcr.io/conduitplatform/$(1):latest ; \
docker tag ghcr.io/conduitplatform/$(1)$(TAG_SUFFIX) conduitplatform/$(1):latest ; \
docker push conduitplatform/$(1):$(2) ; \
docker push ghcr.io/conduitplatform/$(1):latest ; \
docker push conduitplatform/$(1):latest ; \
else \
echo "Skipping latest tag due to alpha, beta, or rc in IMAGE_TAG or DEV=TRUE" ; \
fi
endef
conduit-builder: Dockerfile scripts/Dockerfile.builder
@if [ "$(filter-out $@,$(MAKECMDGOALS))" = "all" ]; then \
docker build --no-cache -t conduit-base:latest -f ./Dockerfile ./ ; \
else \
docker build --no-cache -t conduit-base:latest --build-arg BUILDING_SERVICE=$(filter-out $@,$(MAKECMDGOALS)) -f ./Dockerfile ./ ; \
fi
docker build --no-cache -t conduit-builder:latest -f ./scripts/Dockerfile.builder ./scripts
conduit: conduit-builder
$(call build_docker_image,conduit,$(IMAGE_TAG),./packages)
$(IMAGE_DIRS): conduit-builder
$(eval IMAGE_NAME := $(word 2,$(subst /, ,$@)))
$(call build_docker_image,$(IMAGE_NAME),$(IMAGE_TAG),$@)
.PHONY: all conduit-builder conduit $(IMAGE_DIRS)