From a99346d1ab5925f433b2bd51313f6b449496b3f0 Mon Sep 17 00:00:00 2001 From: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:57:51 +0000 Subject: [PATCH] Actually run built image --- packages/k8s/src/hooks/run-container-step.ts | 5 +++-- packages/k8s/src/k8s/index.ts | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/k8s/src/hooks/run-container-step.ts b/packages/k8s/src/hooks/run-container-step.ts index c64d180..891e618 100644 --- a/packages/k8s/src/hooks/run-container-step.ts +++ b/packages/k8s/src/hooks/run-container-step.ts @@ -26,8 +26,9 @@ export async function runContainerStep( ): Promise { if (stepContainer.dockerfile) { const imagePath = `${generateBuildHandle()}/${generateBuildTag()}` - await containerBuild(stepContainer, imagePath) - throw new Error('Building container actions is not currently supported') + const imageUrl = await containerBuild(stepContainer, imagePath) + // throw new Error('Building container actions is not currently supported') + stepContainer.image = imageUrl } let secretName: string | undefined = undefined diff --git a/packages/k8s/src/k8s/index.ts b/packages/k8s/src/k8s/index.ts index 24686b3..d60d705 100644 --- a/packages/k8s/src/k8s/index.ts +++ b/packages/k8s/src/k8s/index.ts @@ -488,11 +488,13 @@ export async function isPodContainerAlpine( export async function containerBuild( args: RunContainerStepArgs, imagePath: string -): Promise { +): Promise { const cm = registryConfigMap() const secret = registrySecret() const ss = registryStatefulSet() const svc = registryService() + const port = svc?.spec?.ports?.[0]?.nodePort + const registryUri = `localhost:${port}/${imagePath}` const pod = kanikoPod(args.workingDirectory, imagePath) await Promise.all([ k8sApi.createNamespacedConfigMap(namespace(), cm), @@ -522,6 +524,7 @@ export async function containerBuild( console.log(JSON.stringify(err)) throw err } + return registryUri } async function getCurrentNodeName(): Promise {