Skip to content

Commit

Permalink
Allow to pass docker network to child task manager containers
Browse files Browse the repository at this point in the history
In rare occasions (specific docker setup, local development stack), we
might want to run task manager child containers (uploaders) in a
specific Docker network. This adds an environment variable to set in the
task manager which will be further used for children containers
(uploaders)
  • Loading branch information
benoit74 committed Feb 26, 2024
1 parent 791d331 commit e89955a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions workers/app/common/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,24 +614,26 @@ def start_uploader(
if task["upload"][kind]["expiration"]:
command += ["--delete-after", str(task["upload"][kind]["expiration"])]

return run_container(
docker_client,
image=docker_image,
command=command,
detach=True,
environment={"RSA_KEY": str(PRIVATE_KEY)},
labels={
kwargs = {
"image": docker_image,
"command": command,
"detach": True,
"environment": {"RSA_KEY": str(PRIVATE_KEY)},
"labels": {
"zimfarm": "",
"task_id": task["_id"],
"tid": short_id(task["_id"]),
"schedule_name": task["schedule_name"],
"filename": filename,
},
mem_swappiness=0,
mounts=mounts,
name=container_name,
remove=False,
)
"mem_swappiness": 0,
"mounts": mounts,
"name": container_name,
"remove": False,
}
if "DOCKER_NETWORK" in os.environ:
kwargs["network"] = os.getenv("DOCKER_NETWORK")
return run_container(docker_client, **kwargs)


def get_container_logs(docker_client, container_name, tail="all"):
Expand Down

0 comments on commit e89955a

Please sign in to comment.