45 lines
1.2 KiB
Makefile
45 lines
1.2 KiB
Makefile
|
DOCKER ?= docker
|
||
|
APPTAINER ?= apptainer
|
||
|
OVERLAY_DIR ?= ./overlay
|
||
|
SHARED_DIR ?= ./shared
|
||
|
MAX_THREADS ?= $(shell grep -c processor /proc/cpuinfo)
|
||
|
|
||
|
UID := $(shell id -u)
|
||
|
GID := $(shell id -g)
|
||
|
|
||
|
.DEFAULT_GOAL := .docker_build
|
||
|
|
||
|
.docker_build: Dockerfile
|
||
|
"$(DOCKER)" build --build-arg "MAX_THREADS=$(MAX_THREADS)" -t mobileinsight .
|
||
|
touch "$@"
|
||
|
|
||
|
mobileinsight.tar.gz: .docker_build
|
||
|
"$(DOCKER)" save mobileinsight:latest | gzip > "$@"
|
||
|
|
||
|
mobileinsight.sif: mobileinsight.def .docker_build
|
||
|
"$(APPTAINER)" build "$@" "$<"
|
||
|
|
||
|
run: .docker_build
|
||
|
@mkdir -p "$(SHARED_DIR)"
|
||
|
@test -n "$(shell docker image ls -q mobileinsight)" \
|
||
|
|| (echo Cannot find image mobileinsight:latest, has it been built yet? 1>&2 \
|
||
|
&& false)
|
||
|
@"$(DOCKER)" run --rm -it --privileged -v "$(SHARED_DIR):/mnt" \
|
||
|
-e TERM -u root --entrypoint bash mobileinsight:latest
|
||
|
|
||
|
app-run: mobileinsight.sif
|
||
|
@mkdir -p "$(OVERLAY_DIR)"
|
||
|
@lsmod | grep overlay > /dev/null || sudo modprobe overlay
|
||
|
@$(APPTAINER) run --overlay "$(OVERLAY_DIR)" \
|
||
|
-B "/run/user/$(UID)" mobileinsight.sif
|
||
|
|
||
|
clean:
|
||
|
"$(DOCKER)" container prune
|
||
|
"$(DOCKER)" image prune -a
|
||
|
rm -f .docker_build mobileinsight.tar.gz mobileinsight.sif
|
||
|
|
||
|
clean-data:
|
||
|
rm -rf $(OVERLAY_DIR) $(SHARED_DIR)
|
||
|
|
||
|
.PHONY: sc-run run clean clean-data
|