-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
59 lines (41 loc) · 1.49 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
IMAGE_NAME ?= cohortextractor
PYTHON_VERSION ?= python3.8
VIRTUAL_ENV ?= venv
BIN = $(VIRTUAL_ENV)/bin
.PHONY: prodenv
prodenv: $(VIRTUAL_ENV)/prod
.PHONY: devenv
devenv: $(VIRTUAL_ENV)/dev
$(VIRTUAL_ENV)/prod: requirements.prod.txt | $(VIRTUAL_ENV)
$(BIN)/pip install -r requirements.prod.txt
touch $@
$(VIRTUAL_ENV)/dev: $(VIRTUAL_ENV)/prod requirements.dev.txt
$(BIN)/pip install -r requirements.dev.txt
touch $@
requirements.prod.txt: setup.py
@# ensure we have pip-compile
$(MAKE) $(BIN)/pip-compile
$(VIRTUAL_ENV)/bin/pip-compile setup.py --extra drivers -o requirements.prod.txt
requirements.dev.txt: requirements.dev.in requirements.prod.txt
@# ensure we have pip-compile
$(MAKE) $(BIN)/pip-compile
$(VIRTUAL_ENV)/bin/pip-compile requirements.dev.in
# ensure we have pip-tools so we can run pip-compile to boostrap env
$(BIN)/pip-compile: | $(VIRTUAL_ENV)
$(BIN)/pip install pip-tools
# create venv if needed
$(VIRTUAL_ENV):
$(PYTHON_VERSION) -m venv $(VIRTUAL_ENV) && $(BIN)/pip install --upgrade pip
# build the production docker image
.PHONY: docker-build
docker-build: export BUILD_DATE=$(shell date +'%y-%m-%dT%H:%M:%S.%3NZ')
docker-build: export REVISION=$(shell git rev-parse --short HEAD)
docker-build: export VERSION=$(shell git describe --tags)
docker-build: export DOCKER_BUILDKIT=1
docker-build: ENV=dev
docker-build:
docker compose build --pull $(ARGS) $(ENV)
.PHONY: lint
docker-lint:
@docker pull hadolint/hadolint
@docker run --rm -i hadolint/hadolint < Dockerfile