-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (42 loc) · 1.95 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
.PHONY: build deploy image image-create render-content image-finalize lint tests
SERVICE=$(shell basename $(shell git rev-parse --show-toplevel))
REGISTRY=registry.openculinary.org
PROJECT=reciperadar
IMAGE_NAME=${REGISTRY}/${PROJECT}/${SERVICE}
IMAGE_COMMIT := $(shell git rev-parse HEAD)
IMAGE_TAG := $(strip $(if $(shell git status --porcelain --untracked-files=no), latest, ${IMAGE_COMMIT}))
build: image
deploy:
kubectl apply -f k8s
kubectl set image deployments -l app=${SERVICE} ${SERVICE}=${IMAGE_NAME}:${IMAGE_TAG}
image: image-create render-content image-finalize
image-create:
$(eval container=$(shell buildah from docker.io/library/nginx:alpine))
buildah copy $(container) 'etc/nginx/conf.d' '/etc/nginx/conf.d'
buildah run --network none $(container) -- rm -rf '/usr/share/nginx/html' --
render-content: venv
rm -rf public
venv/bin/python -m web.app
image-finalize:
buildah copy $(container) 'public' '/usr/share/nginx/html'
buildah config --port 80 --cmd '/usr/sbin/nginx -g "daemon off;"' $(container)
buildah commit --quiet --rm --squash $(container) ${IMAGE_NAME}:${IMAGE_TAG}
# Virtualenv Makefile pattern derived from https://github.com/bottlepy/bottle/
venv: venv/.installed requirements.txt requirements-dev.txt
venv/bin/pip install --requirement requirements-dev.txt
touch venv
venv/.installed:
python3 -m venv venv
venv/bin/pip install pip-tools
touch venv/.installed
requirements.txt: requirements.in
venv/bin/pip-compile --allow-unsafe --generate-hashes --no-config --no-header --output-file requirements.txt --quiet --strip-extras requirements.in
requirements-dev.txt: requirements.in requirements-dev.in
venv/bin/pip-compile --allow-unsafe --generate-hashes --no-config --no-header --output-file requirements-dev.txt --quiet --strip-extras requirements.in requirements-dev.in
lint: venv
venv/bin/black --check --quiet tests
venv/bin/black --check --quiet web
venv/bin/flake8 tests
venv/bin/flake8 web
tests: venv
venv/bin/pytest tests