Skip to content

Commit b719e1e

Browse files
committed
feat(CLI): expose --tag-base, --verison, and --push for build cmd
Also added documentation for these flags and `--generate`
1 parent 66f3afd commit b719e1e

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

silverback/_cli.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,48 @@ def run(cli_ctx, account, runner_class, recorder_class, max_exceptions, debug, b
131131

132132

133133
@cli.command(section="Local Commands")
134-
@click.option("--generate", is_flag=True, default=False)
134+
@click.option(
135+
"-g",
136+
"--generate",
137+
is_flag=True,
138+
default=False,
139+
help="Generate Dockerfiles first. Defaults to false.",
140+
)
141+
@click.option(
142+
"-t",
143+
"--tag-base",
144+
default=None,
145+
help=(
146+
"The base to use to tag the image. "
147+
"The bot name (or 'bot') is appended to it, following a '-' separator. "
148+
"Defaults to using the name of the folder you are building from."
149+
),
150+
)
151+
@click.option(
152+
"--version",
153+
default="latest",
154+
metavar="VERSION",
155+
help="Version to use in tag. Defaults to 'latest'.",
156+
)
157+
@click.option(
158+
"--push",
159+
is_flag=True,
160+
default=False,
161+
help="Push image to logged-in registry. Defaults to false.",
162+
)
135163
@click.argument("path", required=False, default=None)
136-
def build(generate, path):
137-
"""Generate Dockerfiles and build bot container images"""
164+
def build(generate, tag_base, version, push, path):
165+
"""
166+
Generate Dockerfiles and build bot container images
167+
168+
When '--tag-base' is used, you can control the base of the tag for the image.
169+
For example, '--tag-base project' with bots 'botA.py' and 'botB.py' (under 'bots/') produces
170+
'-t project-bota:latest' and '-t project-botb:latest' respectively.
171+
172+
For building to push to a specific image registry, use '--tag-base' to correctly tag images.
173+
Using '--tag-base ghcr.io/myorg/myproject' with the previous example
174+
'-t ghcr.io/myorg/project-bota:latest' and '-t ghcr.io/myorg/project-botb:latest' respectively.
175+
"""
138176
from silverback._build_utils import (
139177
IMAGES_FOLDER_NAME,
140178
build_docker_images,
@@ -166,7 +204,7 @@ def build(generate, path):
166204
"You can run `silverback build --generate` to generate it and build."
167205
)
168206

169-
build_docker_images()
207+
build_docker_images(tag_base=tag_base, version=version, push=push)
170208

171209

172210
@cli.command(cls=ConnectedProviderCommand, section="Local Commands")

0 commit comments

Comments
 (0)