-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
55 lines (44 loc) · 1.22 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
51
52
53
54
55
.DEFAULT_GOAL := build
GIT_REV := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
TARGET ?= build
CACHE_PATH ?= $(PWD)/cache
OUTPUT_PATH ?= $(PWD)/output
BASE_IMAGE = condaforge/mambaforge:4.9.2-5
CACHE_ARG = --import-cache type=local,src=$(CACHE_PATH) \
--export-cache type=local,dest=$(CACHE_PATH),mode=max
CONFIG_ARG = --opt build-arg:BASE_IMAGE=$(BASE_IMAGE) \
--opt build-arg:CONDA_TOKEN=$(CONDA_TOKEN)
ifeq ($(TARGET),testresult)
OUTPUT_ARG = --output type=local,dest=$(OUTPUT_PATH)
endif
BUILD_ARG = /usr/bin/buildctl-daemonless.sh \
build \
--frontend dockerfile.v0 \
--local context=$(PWD)/$(DOCKERFILE) \
--local dockerfile=$(PWD)/$(DOCKERFILE) \
--opt target=$(TARGET) \
$(CACHE_ARG) \
$(CONFIG_ARG) \
$(OUTPUT_ARG)
ifeq ($(shell which buildctl-daemonless.sh 2>/dev/null),)
BUILD = docker run -it --rm \
--privileged \
--group-add $(shell id -g) \
-v $(PWD):$(PWD) \
-w $(PWD) \
--entrypoint=/bin/sh \
moby/buildkit:master \
$(BUILD_ARG)
else
BUILD = /bin/sh \
$(BUILD_ARG)
endif
.PHONY: upload
upload: TARGET := publish
upload: build
.PHONY: build
build:
$(BUILD_PRE)
$(BUILD)
$(BUILD_POST)