|
|
|
@ -4,6 +4,9 @@ from invoke import task
|
|
|
|
|
|
|
|
|
|
SPEECH_COLLECT_RESPOSITORY = os.environ.get("SPEECH_COLLECT_RESPOSITORY", "registry.runcible.io/speech-collect")
|
|
|
|
|
SPEECH_COLLECT_HELM_CHART_DIR = "./charts/speech-collect"
|
|
|
|
|
SPEECH_COLLECT_HELM_REPO = os.environ.get(
|
|
|
|
|
"SPEECH_COLLECT_HELM_REPO", "https://git.runcible.io/api/packages/androiddrew/helm/api/charts"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
@ -26,13 +29,18 @@ def sync_deps(c):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
|
def build_image(c, dev=True):
|
|
|
|
|
def build_image(c, dev=True, registry_user=None, registry_token=None, push=False, login=False):
|
|
|
|
|
"""Builds the speech-collect container image."""
|
|
|
|
|
context_dir = c.run("pwd", hide=True).stdout.strip()
|
|
|
|
|
commit_sha = c.run("git rev-parse --short HEAD", hide=True).stdout.strip()
|
|
|
|
|
c.run(
|
|
|
|
|
f"docker build --build-arg='COMMIT_SHA={commit_sha}' -t speech-collect:{commit_sha}{'-dev' if dev else ''} {context_dir}"
|
|
|
|
|
)
|
|
|
|
|
image_name = f"{SPEECH_COLLECT_RESPOSITORY}:{commit_sha}{'-dev' if dev else ''}"
|
|
|
|
|
c.run(f"docker build --build-arg='COMMIT_SHA={commit_sha}' -t {image_name} {context_dir}")
|
|
|
|
|
if login:
|
|
|
|
|
if registry_user is None or registry_token is None:
|
|
|
|
|
raise ValueError("--registry_user and --registry_token must be provided if using --login parameter")
|
|
|
|
|
c.run(f"docker login -u {registry_user} -p {registry_token}")
|
|
|
|
|
if push:
|
|
|
|
|
c.run(f"docker push {image_name}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
@ -70,3 +78,17 @@ def package_chart(c, pre_release=None, destination="./build"):
|
|
|
|
|
if pre_release is not None:
|
|
|
|
|
chart_version = chart_version + str(pre_release)
|
|
|
|
|
c.run(f"helm package {SPEECH_COLLECT_HELM_CHART_DIR} --version {chart_version} --destination {destination}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@task(pre=[package_chart])
|
|
|
|
|
def publish_chart(c, repo_user=None, repo_token=None, build_dir="./build"):
|
|
|
|
|
"""Pushes a helm chart to a repository"""
|
|
|
|
|
chart_name = c.run(
|
|
|
|
|
f"helm show chart {SPEECH_COLLECT_HELM_CHART_DIR} | grep name | tail -1 | cut -d ':' -f2 | xargs"
|
|
|
|
|
).stdout.strip()
|
|
|
|
|
chart_version = c.run(
|
|
|
|
|
f"helm show chart {SPEECH_COLLECT_HELM_CHART_DIR} | grep version | tail -1 | cut -d ':' -f2 | xargs"
|
|
|
|
|
).stdout.strip()
|
|
|
|
|
target_chart = f"{chart_name}-{chart_version}.tgz"
|
|
|
|
|
cmd = f"curl --user {repo_user}:{repo_token} -X POST --upload-file {build_dir}/{target_chart} {SPEECH_COLLECT_HELM_REPO}"
|
|
|
|
|
c.run(cmd)
|
|
|
|
|