fix(make): auto-detect docker/podman so Makefile works on either engine

- Makefile: introduce CONTAINER_CMD ?= $(shell command -v docker || echo podman),
  replace all 12 hardcoded `docker` invocations with $(CONTAINER_CMD). User can
  override with `make <target> CONTAINER_CMD=podman` or env export.
- e2e/tests/us1-bootstrap-admin.spec.ts: AC-1.4 regex updated to match the new
  variable form `$(CONTAINER_CMD) exec … flask create-admin` (was hardcoded
  `docker exec`). RUNTIME default also auto-detects (same logic as Makefile)
  so the test exec'es the right engine without a MIMIC_CONTAINER_CMD export.
- e2e/tests/us6-deployment.spec.ts: same RUNTIME auto-detect so the make-dry-run
  regex assertions on lines 75 + 77 match what the Makefile actually emits on
  a podman-only host.
- README + CHANGELOG document the new behavior.

Fixes the user-reported issue: "Le makefile ne fonctionne pas sur ma machine
qui n'a que podman."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Knacky
2026-05-26 12:20:29 +02:00
parent 9ace9ac0d8
commit b3124ba4dd
5 changed files with 38 additions and 16 deletions

View File

@@ -3,16 +3,20 @@ 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)
.PHONY: build start stop restart update logs create-admin update-mitre test-backend test-frontend test-e2e clean
build:
docker build -f docker/Dockerfile -t $(IMAGE) .
$(CONTAINER_CMD) build -f docker/Dockerfile -t $(IMAGE) .
start:
docker run -d --name $(CONTAINER) -p $(PORT):5000 -v $(VOLUME):/data --env-file .env $(IMAGE)
$(CONTAINER_CMD) run -d --name $(CONTAINER) -p $(PORT):5000 -v $(VOLUME):/data --env-file .env $(IMAGE)
stop:
docker stop $(CONTAINER) && docker rm $(CONTAINER)
$(CONTAINER_CMD) stop $(CONTAINER) && $(CONTAINER_CMD) rm $(CONTAINER)
restart:
$(MAKE) stop && $(MAKE) start
@@ -21,7 +25,7 @@ update:
git pull && $(MAKE) build && $(MAKE) restart
logs:
docker logs -f $(CONTAINER)
$(CONTAINER_CMD) logs -f $(CONTAINER)
create-admin:
ifndef USER
@@ -30,7 +34,7 @@ endif
ifndef PASS
$(error PASS is required: make create-admin USER=alice PASS=p4ssw0rd)
endif
docker exec $(CONTAINER) flask create-admin $(USER) $(PASS)
$(CONTAINER_CMD) exec $(CONTAINER) flask create-admin $(USER) $(PASS)
MITRE_URL ?= https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json
@@ -38,13 +42,13 @@ update-mitre:
@mkdir -p backend/data/mitre
@curl -fsSL "$(MITRE_URL)" -o backend/data/mitre/enterprise-attack.json
@echo "MITRE bundle updated"
@if docker ps --format '{{.Names}}' | grep -q "^$(CONTAINER)$$"; then \
@if $(CONTAINER_CMD) ps --format '{{.Names}}' | grep -q "^$(CONTAINER)$$"; then \
echo "Restarting $(CONTAINER) to reload MITRE bundle..."; \
docker restart $(CONTAINER); \
$(CONTAINER_CMD) restart $(CONTAINER); \
fi
test-backend:
docker exec $(CONTAINER) pytest -q backend/tests/
$(CONTAINER_CMD) exec $(CONTAINER) pytest -q backend/tests/
test-frontend:
cd frontend && npm run test -- --run
@@ -53,6 +57,6 @@ test-e2e:
cd e2e && npx playwright test
clean:
-docker rm -f $(CONTAINER) 2>/dev/null
-docker volume rm $(VOLUME) 2>/dev/null
-$(CONTAINER_CMD) rm -f $(CONTAINER) 2>/dev/null
-$(CONTAINER_CMD) volume rm $(VOLUME) 2>/dev/null
rm -rf backend/__pycache__ frontend/node_modules frontend/dist