2023-03-13 17:03:47 +00:00
|
|
|
from tutor import fmt, hooks, utils
|
|
|
|
from tutor.types import Config, get_typed
|
2021-02-25 08:09:14 +00:00
|
|
|
|
2019-07-02 20:16:44 +00:00
|
|
|
|
2021-04-06 10:09:00 +00:00
|
|
|
def get_tag(config: Config, name: str) -> str:
|
|
|
|
key = "DOCKER_IMAGE_" + name.upper().replace("-", "_")
|
|
|
|
return get_typed(config, key, str)
|
2019-10-22 14:13:50 +00:00
|
|
|
|
|
|
|
|
2021-02-25 08:09:14 +00:00
|
|
|
def build(path: str, tag: str, *args: str) -> None:
|
2022-02-07 17:11:43 +00:00
|
|
|
fmt.echo_info(f"Building image {tag}")
|
2023-03-13 17:03:47 +00:00
|
|
|
command = hooks.Filters.DOCKER_BUILD_COMMAND.apply(
|
|
|
|
["build", "-t", tag, *args, path]
|
|
|
|
)
|
|
|
|
utils.docker(*command)
|
2019-07-02 20:16:44 +00:00
|
|
|
|
2019-07-03 14:09:33 +00:00
|
|
|
|
2021-02-25 08:09:14 +00:00
|
|
|
def pull(tag: str) -> None:
|
2022-02-07 17:11:43 +00:00
|
|
|
fmt.echo_info(f"Pulling image {tag}")
|
2020-11-14 11:26:06 +00:00
|
|
|
utils.docker("pull", tag)
|
2019-07-02 20:16:44 +00:00
|
|
|
|
2019-07-03 14:09:33 +00:00
|
|
|
|
2021-02-25 08:09:14 +00:00
|
|
|
def push(tag: str) -> None:
|
2022-02-07 17:11:43 +00:00
|
|
|
fmt.echo_info(f"Pushing image {tag}")
|
2020-11-14 11:26:06 +00:00
|
|
|
utils.docker("push", tag)
|