-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
162 lines (131 loc) · 3.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
help:
@cat Makefile
@echo
@echo "Usage: make [TARGET] [VARIABLE=value]"
@echo "Perform a dry run with:"
@echo " make [TARGET] -n"
BASE ?= oracular
GIT_TAG ?= 2024.2
TEST_SUITE ?= -
CHASTE_IMAGE ?= chaste/release
CHASTE_DIR ?= "/home/chaste"
CHASTE_DATA_VOLUME ?= chaste_data
OUT ?= auto
FRESH ?=
EXTRA_BUILD_FLAGS ?=
# Optional mounts
# PROJECTS ?= "${HOME}/projects"
# TEST_OUTPUT ?= "${HOME}/output"
# https://github.com/pytorch/pytorch/blob/main/docker.Makefile
MULTI_ARCH_BUILD ?= true
ifeq ("$(MULTI_ARCH_BUILD)", "true")
PUSH = true
PLATFORM ?= "linux/amd64,linux/arm64/v8"
BUILD = buildx build --push --platform $(PLATFORM) -o type=image
else
BUILD = build
endif
PUSH ?= false
ifeq ("$(PUSH)", "true")
base develop main release: login
endif
PROGRESS = --progress=$(OUT)
all: base release
.PHONY: base develop main release
# base develop main release: build
base develop main release:
docker $(BUILD) \
$(TARGET) \
$(PROGRESS) \
$(EXTRA_BUILD_FLAGS) \
$(BUILD_ARGS) \
$(DOCKER_TAGS) \
-f $(DOCKER_FILE) .
TARGET?=
base: TARGET = --target base
develop main: TARGET = --target build
ifdef FRESH
EXTRA_BUILD_FLAGS += --no-cache
endif
BUILD_ARGS = --build-arg BASE=$(BASE) \
--build-arg CHASTE_DIR=$(CHASTE_DIR)
develop main release: BUILD_ARGS += --build-arg GIT_TAG=$(GIT_TAG) \
--build-arg CMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
--build-arg Chaste_ERROR_ON_WARNING=$(Chaste_ERROR_ON_WARNING) \
--build-arg Chaste_UPDATE_PROVENANCE=$(Chaste_UPDATE_PROVENANCE) \
--build-arg TEST_SUITE=$(TEST_SUITE)
develop main: CMAKE_BUILD_TYPE="Debug"
develop main: Chaste_ERROR_ON_WARNING ?= "ON"
develop main: Chaste_UPDATE_PROVENANCE="OFF"
develop main: GIT_TAG=$@
release: CMAKE_BUILD_TYPE="Release"
release: Chaste_ERROR_ON_WARNING ?= "OFF"
release: Chaste_UPDATE_PROVENANCE="ON"
# release: TEST_SUITE = "Continuous"
base develop main release: CHASTE_IMAGE = chaste/$@
base develop main release: DOCKER_TAGS = -t $(CHASTE_IMAGE)
base develop main: DOCKER_TAGS += -t $(CHASTE_IMAGE):$(BASE)
release: DOCKER_TAGS += -t $(CHASTE_IMAGE):$(GIT_TAG) \
-t $(CHASTE_IMAGE):$(BASE)-$(GIT_TAG)
DOCKER_FILE ?= Dockerfile
# release: build test push
# NOTE: To build for multiple architectures, it may first be necessary to run this:
.PHONY: setup
BUILDX_ENV ?= multiarch
setup:
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --name $(BUILDX_ENV) --driver docker-container --bootstrap --use
.PHONY: login
login:
docker login
.PHONY: clean
clean:
docker system prune
.PHONY: stats
stats:
docker stats
.PHONY: pull
pull:
docker pull $(CHASTE_IMAGE):$(GIT_TAG)
.PHONY: push
push:
docker push $(CHASTE_IMAGE):$(GIT_TAG)
docker push $(CHASTE_IMAGE):$(BASE)-$(GIT_TAG)
MOUNTS = -v $(CHASTE_DATA_VOLUME):$(CHASTE_DIR)
ifdef PROJECTS
MOUNTS += -v $(PROJECTS):$(CHASTE_DIR)/projects
endif
ifdef TEST_OUTPUT
MOUNTS += -v $(TEST_OUTPUT):$(CHASTE_DIR)/output
endif
# NOTE: When a container is started which creates a new volume, the contents of the mount point are copied to the volume
.PHONY: run
run:
docker run -it --init --rm $(MOUNTS) $(CHASTE_IMAGE)
.PHONY: test
test:
docker run -t --init --rm --env CMAKE_BUILD_TYPE=Debug \
$(CHASTE_IMAGE) test.sh $(TEST_SUITE) c
.PHONY: build-info
build-info:
docker run -t --init --rm $(CHASTE_IMAGE) get_chaste_info.sh
.PHONY: info
info:
@echo "BASE: $(BASE)"
@echo "GIT_TAG: $(GIT_TAG)"
@echo "TEST_SUITE: $(TEST_SUITE)"
@echo "CHASTE_IMAGE: $(CHASTE_IMAGE)"
@echo "CHASTE_DIR: $(CHASTE_DIR)"
@echo "CHASTE_DATA_VOLUME: $(CHASTE_DATA_VOLUME)"
@echo "Mounts: $(MOUNTS)"
@echo "FRESH: $(FRESH)"
@echo "OUT: $(OUT)"
@echo "EXTRA_BUILD_FLAGS: $(EXTRA_BUILD_FLAGS)"
@echo "MULTI_ARCH_BUILD: $(MULTI_ARCH_BUILD)"
@echo "PUSH: $(PUSH)"
@echo "PLATFORM: $(PLATFORM)"
docker -v
# lsb_release -a
.PHONY: verbose
verbose: info
docker system info