2023-03-13 17:03:47 +00:00
|
|
|
from tutor import fmt, hooks, utils
|
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-04-27 18:25:20 +00:00
|
|
|
build_command = ["build", f"--tag={tag}", *args, path]
|
2023-10-27 08:54:23 +00:00
|
|
|
# `buildx` can be removed once Tutor requires Docker v23+. At that point, BuildKit will be
|
|
|
|
# enabled by default for all Docker users.
|
|
|
|
build_command.insert(0, "buildx")
|
2023-04-03 18:44:15 +00:00
|
|
|
command = hooks.Filters.DOCKER_BUILD_COMMAND.apply(build_command)
|
2023-03-13 17:03:47 +00:00
|
|
|
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)
|