diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-11-23 10:19:19 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-11-23 10:20:33 +0100 |
commit | b3e66d97993318e91c0ff634fec62978f6530785 (patch) | |
tree | d3f1be83a44315588cc98bc02332beb8fcaa02c6 /Makefile | |
parent | f62c989e9a3dd9a25c288ecde38ad234aee63e4e (diff) | |
download | koszko-org-server-b3e66d97993318e91c0ff634fec62978f6530785.tar.gz koszko-org-server-b3e66d97993318e91c0ff634fec62978f6530785.zip |
facilitate starting a test container without using `mount` to create the host directories container expects to exist
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -25,7 +25,10 @@ GUIX_SHELL = $(GUIX_TM) shell KOSZKO_ORG_WEBSITE_INFO = \ subrepos/koszko-org-website/src/koszko_org_website.egg-info/PKG-INFO -LOGDIR = "/tmp/$$(pwd | sed 's|/|!|g')!log" +TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')!!test-root" +TEST_WWW_DIR=$(TEST_ROOT_DIR)/var/www +TEST_ALL_LOGS_DIR = $(TEST_ROOT_DIR)/var/log +TEST_LOG_DIR = $(TEST_ALL_LOGS_DIR)/guix-container all: | container-runner.touchfile log @@ -45,18 +48,31 @@ hosts: hosts-extra /etc/hosts cat $^ > $@ log: - ln -sf $(LOGDIR) $@ + ln -sf $(TEST_LOG_DIR) $@ -start-container: guix-container.sh container-runner.touchfile | log - unshare --mount ./run-with-fake-mounts.sh $(LOGDIR) \ - ./$< start -e ./container-runner -p ./pidfile -l $(LOGDIR) +prepare-test-root: + rm -rf $(TEST_ROOT_DIR) + @# Prepare replacement `/var/www` + mkdir -p $(TEST_WWW_DIR)/koszko.org/html + printf ':D\n' > $(TEST_WWW_DIR)/koszko.org/html/index.html + @# Prepare replacement `/var/log` + mkdir -p $(TEST_ALL_LOGS_DIR) + +GUIX_CONTAINER_FLAGS = \ + -e ./container-runner -p ./pidfile \ + -l $(TEST_LOG_DIR) \ + -w $(TEST_WWW_DIR) + +start-container: guix-container.sh container-runner.touchfile \ + prepare-test-root | log + ./$< start $(GUIX_CONTAINER_FLAGS) stop-container: guix-container.sh - ./$< stop -e ./container-runner -p ./pidfile + ./$< stop $(GUIX_CONTAINER_FLAGS) -restart-container: guix-container.sh container-runner.touchfile | log - unshare --mount ./run-with-fake-mounts.sh $(LOGDIR) \ - ./$< restart -e ./container-runner -p ./pidfile -l $(LOGDIR) +restart-container: guix-container.sh container-runner.touchfile \ + prepare-test-root | log + ./$< restart $(GUIX_CONTAINER_FLAGS) enter-container: pidfile nsenter -a -t "$$(cat pidfile)" \ @@ -86,6 +102,7 @@ clean: clean-runner .PHONY: all \ clean-runner clean \ + prepare-test-root \ start-container stop-container restart-container \ enter-container fake-client \ install reinstall \ |