forked from comic/grand-challenge.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
155 lines (128 loc) · 5.44 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
USER_ID=$(shell id -u)
PYTHON_VERSION="3.10"
POETRY_HASH=$(shell shasum -a 512 poetry.lock | cut -c 1-8)
GIT_COMMIT_ID=$(shell git describe --always --dirty)
GIT_BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD | sed "s/[^[:alnum:]]//g")
GRAND_CHALLENGE_HTTP_REPOSITORY_URI=public.ecr.aws/diag-nijmegen/grand-challenge/http
GRAND_CHALLENGE_WEB_REPOSITORY_URI=public.ecr.aws/diag-nijmegen/grand-challenge/web
GRAND_CHALLENGE_WEB_TEST_REPOSITORY_URI=public.ecr.aws/diag-nijmegen/grand-challenge/web-test
GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI=public.ecr.aws/diag-nijmegen/grand-challenge/web-base
GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI=public.ecr.aws/diag-nijmegen/grand-challenge/web-test-base
build_web_test:
@docker pull $(GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH) || { \
docker buildx build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--target test-base \
-t $(GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH) \
-f dockerfiles/web-base/Dockerfile \
.; \
}
docker buildx build\
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--build-arg COMMIT_ID=$(GIT_COMMIT_ID) \
--build-arg POETRY_HASH=$(POETRY_HASH) \
--build-arg GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI=$(GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI) \
--build-arg GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI=$(GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI) \
--target test \
-t $(GRAND_CHALLENGE_WEB_TEST_REPOSITORY_URI):$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH) \
-t $(GRAND_CHALLENGE_WEB_TEST_REPOSITORY_URI):latest \
-f dockerfiles/web/Dockerfile \
.
build_web_dist:
@docker pull $(GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH) || { \
docker buildx build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--target base \
-t $(GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH) \
-f dockerfiles/web-base/Dockerfile \
.; \
}
DOCKER_BUILDKIT=0 docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--build-arg COMMIT_ID=$(GIT_COMMIT_ID) \
--build-arg POETRY_HASH=$(POETRY_HASH) \
--build-arg GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI=$(GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI) \
--build-arg GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI=$(GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI) \
--network grand-challengeorg_default \
--target dist \
-t $(GRAND_CHALLENGE_WEB_REPOSITORY_URI):$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH) \
-t $(GRAND_CHALLENGE_WEB_REPOSITORY_URI):latest \
-f dockerfiles/web/Dockerfile \
.
build_http:
docker buildx build \
-t $(GRAND_CHALLENGE_HTTP_REPOSITORY_URI):$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH) \
-t $(GRAND_CHALLENGE_HTTP_REPOSITORY_URI):latest \
dockerfiles/http
push_web_base:
docker push $(GRAND_CHALLENGE_WEB_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH)
push_web_test_base:
docker push $(GRAND_CHALLENGE_WEB_TEST_BASE_REPOSITORY_URI):$(PYTHON_VERSION)-$(POETRY_HASH)
push_web:
docker push $(GRAND_CHALLENGE_WEB_REPOSITORY_URI):$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH)
docker push $(GRAND_CHALLENGE_WEB_REPOSITORY_URI):latest
push_http:
docker push $(GRAND_CHALLENGE_HTTP_REPOSITORY_URI):$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH)
docker push $(GRAND_CHALLENGE_HTTP_REPOSITORY_URI):latest
build: build_web_test build_web_dist build_http
migrate:
docker compose run --rm web python manage.py migrate
check_migrations:
docker compose run --rm web python manage.py makemigrations --dry-run --check
migrations:
docker compose run -u $(USER_ID) --rm web python manage.py makemigrations
runserver: build_web_test build_http development_fixtures
bash -c "trap 'docker compose down' EXIT; docker compose up"
rundeps:
bash -c "trap 'docker compose down' EXIT; docker compose up postgres minio.localhost redis registry"
minio:
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
--rm \
web \
bash -c "python manage.py runscript minio"
development_fixtures: scripts/algorithm_io.tar
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
-v $(shell readlink -f ./demo/):/app/demo:ro \
--rm \
web \
bash -c "python manage.py migrate && python manage.py runscript minio development_fixtures"
demo_fixtures:
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
-v $(shell readlink -f ./demo/):/app/demo:ro \
--rm \
web \
bash -c "python manage.py runscript demo_fixtures"
retina_archive_structures:
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
--rm \
web \
bash -c "python manage.py runscript create_retina_archive_structures"
scripts/algorithm_io.tar:
docker buildx build -t algorithm_io app/tests/resources/gc_demo_algorithm/
docker save algorithm_io -o scripts/algorithm_io.tar
chmod a+r scripts/algorithm_io.tar
algorithm_evaluation_fixtures: scripts/algorithm_io.tar
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
--rm \
web \
python manage.py runscript algorithm_evaluation_fixtures
cost_fixtures: scripts/algorithm_io.tar
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
--rm \
web \
python manage.py runscript cost_fixtures
superuser:
docker compose run \
-v $(shell readlink -f ./scripts/):/app/scripts:ro \
--rm \
web \
python manage.py runscript create_superuser
.PHONY: docs
docs:
docker compose run --rm -u $(USER_ID) web bash -c "cd docs && make html"