-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (36 loc) · 968 Bytes
/
Copy pathMakefile
File metadata and controls
45 lines (36 loc) · 968 Bytes
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
IMAGE := node:20-alpine
WORKDIR := /app
## Detect container engine (podman or docker)
CONTAINER_ENGINE := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)
# Use :Z bind-mount option only with Podman (SELinux relabeling)
ifneq (,$(findstring podman,$(CONTAINER_ENGINE)))
MOUNT_OPT := :Z
endif
VOLUME := -v $(PWD):$(WORKDIR)$(MOUNT_OPT)
.PHONY: shell test lint install clean
install:
ifdef CONTAINER_ENGINE
$(CONTAINER_ENGINE) run --rm $(VOLUME) -w $(WORKDIR) $(IMAGE) npm install
else
npm install
endif
test:
ifdef CONTAINER_ENGINE
$(CONTAINER_ENGINE) run --rm $(VOLUME) -w $(WORKDIR) $(IMAGE) npx mocha
else
npx mocha
endif
lint:
ifdef CONTAINER_ENGINE
$(CONTAINER_ENGINE) run --rm $(VOLUME) -w $(WORKDIR) $(IMAGE) npx eslint .
else
npx eslint .
endif
shell:
ifdef CONTAINER_ENGINE
$(CONTAINER_ENGINE) run --rm -it $(VOLUME) -w $(WORKDIR) $(IMAGE) sh
else
@echo "no container engine available"
endif
clean:
rm -rf node_modules