Skip to content

Commit

Permalink
new attempt at dind wacz
Browse files Browse the repository at this point in the history
  • Loading branch information
msramalho committed Feb 22, 2024
1 parent 5324d56 commit 9fd4bb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/auto_archiver/enrichers/wacz_enricher.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,19 @@ def configs() -> dict:

def setup(self) -> None:
self.use_docker = os.environ.get('WACZ_ENABLE_DOCKER') or not os.environ.get('RUNNING_IN_DOCKER')
self.docker_in_docker = os.environ.get('WACZ_ENABLE_DOCKER') and os.environ.get('RUNNING_IN_DOCKER')

self.cwd_dind = f"crawls/crawls{random_str(8)}"
self.browsertrix_home_host = os.environ.get('BROWSERTRIX_HOME_HOST')
self.browsertrix_home_container = os.environ.get('BROWSERTRIX_HOME_CONTAINER') or self.browsertrix_home_host
# create crawls folder if not exists, so it can be safely removed in cleanup
if self.use_docker:
if self.browsertrix_home_container:
os.makedirs(self.browsertrix_home_container, exist_ok=True)
if self.docker_in_docker:
os.makedirs(self.cwd_dind, exist_ok=True)

def cleanup(self) -> None:
if self.use_docker:
if self.browsertrix_home_container:
logger.debug(f"Removing {self.browsertrix_home_container=}")
shutil.rmtree(self.browsertrix_home_container, ignore_errors=True)


if self.docker_in_docker:
logger.debug(f"Removing {self.cwd_dind=}")
shutil.rmtree(self.cwd_dind, ignore_errors=True)

def download(self, item: Metadata) -> Metadata:
# this new Metadata object is required to avoid duplication
Expand Down Expand Up @@ -84,6 +83,9 @@ def enrich(self, to_enrich: Metadata) -> bool:
"--behaviors", "autoscroll,autoplay,autofetch,siteSpecific",
"--behaviorTimeout", str(self.timeout),
"--timeout", str(self.timeout)]

if self.docker_in_docker:
cmd.extend(["--cwd", self.cwd_dind])

# call docker if explicitly enabled or we are running on the host (not in docker)
if self.use_docker:
Expand Down
2 changes: 1 addition & 1 deletion src/auto_archiver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_MINOR = "9"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "4"
_PATCH = "5"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""
Expand Down

0 comments on commit 9fd4bb5

Please sign in to comment.