-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
88 lines (72 loc) · 2.24 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
GIT_REV := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
REGISTRY := $(if $(REGISTRY),$(REGISTRY)/,nimbus2.llnl.gov/default/)
VERSION = $(shell cat $(DOCKERFILE)/VERSION)
TAG = $(REGISTRY)$(NAME):$(VERSION)$(if $(findstring devel,$(GIT_BRANCH)),-$(GIT_REV),)
TARGET ?= production
CONDA_VERSION ?= 4.8.2
CACHE_PATH ?= $(PWD)/cache
OUTPUT_PATH ?= $(PWD)/output
BASE_IMAGE = nimbus2.llnl.gov/default/compute-base:1.0.0
CACHE_ARG = --import-cache type=local,src=$(CACHE_PATH) \
--export-cache type=local,dest=$(CACHE_PATH),mode=max
CONFIG_ARG = --opt build-arg:CONTAINER_IMAGE=$(TAG) \
--opt build-arg:CONDA_VERSION=$(CONDA_VERSION) \
--opt build-arg:BASE_IMAGE=$(BASE_IMAGE)
ifeq ($(TARGET),testresult)
OUTPUT_ARG = --output type=local,dest=$(OUTPUT_PATH)
else ifeq ($(shell which docker 2>/dev/null),)
OUTPUT_ARG = --output type=image,name=$(TAG),push=true
else
OUTPUT_ARG = --output type=docker,name=$(TAG),dest=$(OUTPUT_PATH)/image.tar.gz
BUILD_POST = cat $(OUTPUT_PATH)/image.tar.gz | docker load; \
echo $(TAG)
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: base
base: NAME := compute-base
base: DOCKERFILE := compute/base
base: BASE_IMAGE := condaforge/mambaforge:4.9.2-5
base: build
.PHONY: provisioner
provisioner: NAME := compute-provisioner
provisioner: DOCKERFILE := compute/compute_provisioner
provisioner: build
.PHONY: tasks
tasks: NAME := compute-tasks
tasks: DOCKERFILE := compute/compute_tasks
tasks: build
.PHONY: wps
wps: NAME := compute-wps
wps: DOCKERFILE := compute/compute_wps
wps: build
.PHONY: thredds
thredds: NAME := compute-thredds
thredds: DOCKERFILE := docker/thredds
thredds: build
.PHONY: build
build:
$(BUILD_PRE)
$(BUILD)
$(BUILD_POST)