Files
mimic/Makefile
T

62 lines
1.9 KiB
Makefile
Raw Normal View History

2026-05-26 09:37:53 +02:00
PORT ?= 5000
IMAGE ?= mimic:latest
CONTAINER ?= mimic
VOLUME ?= mimic-data
# Container engine: auto-detect docker first, fall back to podman.
# Override explicitly with `make <target> CONTAINER_CMD=podman` or `export CONTAINER_CMD=podman`.
CONTAINER_CMD ?= $(shell if command -v docker >/dev/null 2>&1; then echo docker; else echo podman; fi)
2026-05-26 09:37:53 +02:00
.PHONY: build start stop restart update logs create-admin update-mitre test-backend test-frontend test-e2e clean
build:
$(CONTAINER_CMD) build -f docker/Dockerfile -t $(IMAGE) .
2026-05-26 09:37:53 +02:00
start:
$(CONTAINER_CMD) run -d --name $(CONTAINER) -p $(PORT):5000 -v $(VOLUME):/data --env-file .env $(IMAGE)
2026-05-26 09:37:53 +02:00
stop:
$(CONTAINER_CMD) stop $(CONTAINER) && $(CONTAINER_CMD) rm $(CONTAINER)
2026-05-26 09:37:53 +02:00
restart:
$(MAKE) stop && $(MAKE) start
update:
git pull && $(MAKE) build && $(MAKE) restart
logs:
$(CONTAINER_CMD) logs -f $(CONTAINER)
2026-05-26 09:37:53 +02:00
create-admin:
ifndef USER
$(error USER is required: make create-admin USER=alice PASS=p4ssw0rd)
endif
ifndef PASS
$(error PASS is required: make create-admin USER=alice PASS=p4ssw0rd)
endif
$(CONTAINER_CMD) exec $(CONTAINER) flask create-admin $(USER) $(PASS)
2026-05-26 09:37:53 +02:00
MITRE_URL ?= https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json
2026-05-26 09:37:53 +02:00
update-mitre:
@mkdir -p backend/data/mitre
@curl -fsSL "$(MITRE_URL)" -o backend/data/mitre/enterprise-attack.json
@echo "MITRE bundle updated"
@if $(CONTAINER_CMD) ps --format '{{.Names}}' | grep -q "^$(CONTAINER)$$"; then \
echo "Restarting $(CONTAINER) to reload MITRE bundle..."; \
$(CONTAINER_CMD) restart $(CONTAINER); \
fi
2026-05-26 09:37:53 +02:00
test-backend:
$(CONTAINER_CMD) exec $(CONTAINER) pytest -q backend/tests/
2026-05-26 09:37:53 +02:00
test-frontend:
cd frontend && npm run test -- --run
test-e2e:
cd e2e && npx playwright test
clean:
-$(CONTAINER_CMD) rm -f $(CONTAINER) 2>/dev/null
-$(CONTAINER_CMD) volume rm $(VOLUME) 2>/dev/null
2026-05-26 09:37:53 +02:00
rm -rf backend/__pycache__ frontend/node_modules frontend/dist