-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (38 loc) · 1.33 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
47
48
49
50
# Change this to your image name
IMAGE_TAG ?= latest
IMAGE_NAME ?= nadavtasher/toolchains
# Choose the image flavor
IMAGE_FLAVOR ?= online
# Export variables for usage in recipes
export IMAGE_TAG IMAGE_NAME
# Paths to sources
SOURCE_DIRECTORY := image
# Base repository branch
SOURCE_BRANCH := master
# If we are on the upstream branch, tag the image with a version
ifeq ($(shell git rev-parse --abbrev-ref HEAD),$(SOURCE_BRANCH))
IMAGE_TAG := $(shell git show --quiet --date=format:%Y.%m.%d --format=%cd)
else
IMAGE_TAG := develop
endif
.PHONY: all
all: image
# If the repository has uncommited changes, tag the image as dirty
ifneq ($(shell git status --porcelain),)
IMAGE_TAG := $(IMAGE_TAG)-dirty
endif
.PHONY: image
image:
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile.$(IMAGE_FLAVOR) --load --tag $(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: release
release:
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile.$(IMAGE_FLAVOR) --push --platform linux/amd64 --tag $(IMAGE_NAME):$(IMAGE_TAG) --tag $(IMAGE_NAME):latest
.PHONY: run
run: image
@docker run --rm -it -v $$PWD/build:/build -w /build -h builder --tmpfs /tmp $(IMAGE_NAME):$(IMAGE_TAG) bash
.PHONY: test
test: image
$(MAKE) -C example container COMMAND="make"
.PHONY: bash
bash: image
$(MAKE) -C example container COMMAND="bash"