-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
46 lines (34 loc) · 1.77 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
.PHONY: build-dev build deploy image image-create webpack license-check 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 --short HEAD)
IMAGE_TAG := $(strip $(if $(shell git status --porcelain --untracked-files=no), latest, ${IMAGE_COMMIT}))
MODE = 'development'
build : MODE = 'production'
build-dev: image
build: image
deploy:
kubectl apply -f k8s
kubectl set image deployments -l app=${SERVICE} ${SERVICE}=${IMAGE_NAME}:${IMAGE_TAG}
image: image-create webpack license-check 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' --
webpack:
(test -f public/reciperadar.webmanifest && rm -rf public) || true
npx webpack --mode ${MODE}
license-check:
$(eval licenses=$(shell jq --raw-output ".dependencies | keys | .[]" "package.json" | grep --file - --line-regexp "public/licenses.txt" | wc --lines))
$(eval packages=$(shell jq --raw-output ".dependencies | keys | .[]" "package.json" | wc --lines))
@if [ "${licenses}" -ne "${packages}" ]; then echo "error: only ${licenses} of ${packages} top-level dependencies found in licenses.txt"; exit 1; fi;
image-finalize:
buildah copy $(container) 'public' '/usr/share/nginx/html'
buildah config --cmd '/usr/sbin/nginx -g "daemon off;"' --port 80 $(container)
buildah commit --omit-timestamp --quiet --rm --squash $(container) ${IMAGE_NAME}:${IMAGE_TAG}
lint:
npx eslint src
tests:
npx mocha --mode ${MODE} --require setup.mjs --require ts-node/register 'src/**/*.spec.ts'