Skip to content

Commit

Permalink
use local dockerfile path over git context
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushshah15 committed Dec 31, 2024
1 parent 8b07a60 commit df51985
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,17 @@ export async function getInputs(): Promise<Inputs> {
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
Expand Down

0 comments on commit df51985

Please sign in to comment.