generated from viaacode/prefect-flow-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infra_block.py
26 lines (22 loc) · 928 Bytes
/
infra_block.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from prefect.infrastructure.docker import DockerContainer, DockerRegistry
import argparse
def save_image(image_name, name, registry=None) -> None:
docker_registry = DockerRegistry.load(registry)
docker_container = DockerContainer(
image=image_name,
auto_remove=True,
image_registry=docker_registry,
image_pull_policy="ALWAYS",
)
docker_container.save(name=name, overwrite=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Save a Docker container")
parser.add_argument("--image", required=True, help="Docker image to run")
parser.add_argument("--name", required=True, help="Name of the block")
parser.add_argument(
"--registry",
required=False,
help="Docker registry (the block which it contains), default docker.io",
)
args = parser.parse_args()
save_image(args.image, args.name, args.registry)