From df5198584699c17a352e138470ecc3cad04d2954 Mon Sep 17 00:00:00 2001 From: Aayush Date: Tue, 31 Dec 2024 02:01:43 -0500 Subject: [PATCH] use local dockerfile path over git context --- src/context.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/context.ts b/src/context.ts index b0b0f8b18..a681570b6 100644 --- a/src/context.ts +++ b/src/context.ts @@ -89,18 +89,17 @@ export async function getInputs(): Promise { export function getDockerfilePath(inputs: Inputs): string | null { try { const context = inputs.context || Context.gitContext(); - const normalizedContext = path.normalize(context); let dockerfilePath: string; if (inputs.file) { - const normalizedFile = path.normalize(inputs.file); - dockerfilePath = normalizedFile.startsWith(normalizedContext) ? normalizedFile : path.join(normalizedContext, normalizedFile); + // If context is git context, just use the file path directly + dockerfilePath = context === Context.gitContext() ? inputs.file : path.join(path.normalize(context), inputs.file); } else if (inputs['dockerfile']) { - const normalizedDockerfile = path.normalize(inputs['dockerfile']); - dockerfilePath = normalizedDockerfile.startsWith(normalizedContext) ? normalizedDockerfile : path.join(normalizedContext, normalizedDockerfile); + // If context is git context, just use the dockerfile path directly + dockerfilePath = context === Context.gitContext() ? inputs['dockerfile'] : path.join(path.normalize(context), inputs['dockerfile']); } else { - // Default to Dockerfile in the context directory - dockerfilePath = path.join(normalizedContext, 'Dockerfile'); + // If context is git context, just use 'Dockerfile' + dockerfilePath = context === Context.gitContext() ? 'Dockerfile' : path.join(path.normalize(context), 'Dockerfile'); } // Verify the file exists