From 1ec306a028f2daa316419382de05837af8701aff Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Mon, 19 May 2025 15:01:09 -0400 Subject: [PATCH] feat: support custom run dir, tmpfs --- README.md | 13 +++++++++++++ start.py | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 372f55d..9554cbf 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ docker run --detach \ | SHARED_RSYNC_THREADS | shared:rsync_threads | | `20` | | WARRIOR_ID | warrior_id | | | | CONCURRENT_ITEMS | concurrent_items | | `3` | +| WARRIOR_RUN_DIR | | | `/home/warrior` | ## Other Ways to Run @@ -132,3 +133,15 @@ First edit the `docker-compose.yml` file with any configuration keys (as describ cd examples docker compose up -d ``` + +#### Run using tmpfs + +The Warrior uses disk as scratch space. You may want to use a `tmpfs` mount to [prevent unnecessary wear and tear](https://github.com/ArchiveTeam/warrior-dockerfile/issues/83) if you have RAM to spare. Docker Compose example: + +``` + warrior: + environment: + WARRIOR_RUN_DIR: /warrior-tmp + tmpfs: + - /warrior-tmp:exec,mode=777,uid=1000,gid=1000 +``` diff --git a/start.py b/start.py index 8857c80..7872329 100644 --- a/start.py +++ b/start.py @@ -1,8 +1,18 @@ import json import os import subprocess +import shutil -CONFIG_FILE = 'projects/config.json' +DEFAULT_RUN_DIR = '/home/warrior' +WARRIOR_RUN_DIR = os.getenv('WARRIOR_RUN_DIR', DEFAULT_RUN_DIR) +CONFIG_FILE = os.path.join(WARRIOR_RUN_DIR, 'projects/config.json') + +# copy data/projects from image to the custom run dir +if WARRIOR_RUN_DIR != DEFAULT_RUN_DIR: + for dir_name in ['data', 'projects']: + dst = os.path.join(WARRIOR_RUN_DIR, dir_name) + src = os.path.join(DEFAULT_RUN_DIR, dir_name) + shutil.copytree(src, dst) try: with open(CONFIG_FILE, 'r') as fp: @@ -24,9 +34,9 @@ [ "run-warrior3", "--projects-dir", - "/home/warrior/projects", + os.path.join(WARRIOR_RUN_DIR, "projects"), "--data-dir", - "/home/warrior/data", + os.path.join(WARRIOR_RUN_DIR, "data"), "--warrior-hq", "https://warriorhq.archiveteam.org", "--port",