From f9cc8fdaed4b9bdcb8b5dbc88f5970337b8e0344 Mon Sep 17 00:00:00 2001 From: rtoohil Date: Sun, 30 Nov 2025 11:41:08 -0500 Subject: [PATCH 1/2] Handle context path from compose file to find appropriate files and paths --- .../Commands/ComposeUp.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/Container-Compose/Commands/ComposeUp.swift b/Sources/Container-Compose/Commands/ComposeUp.swift index 126d637..42d4d6f 100644 --- a/Sources/Container-Compose/Commands/ComposeUp.swift +++ b/Sources/Container-Compose/Commands/ComposeUp.swift @@ -598,16 +598,25 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable { return imageToRun } + // Resolve context path (handle absolute paths) + let contextPath: String + if buildConfig.context.hasPrefix("/") || buildConfig.context.hasPrefix("~") { + contextPath = buildConfig.context + } else { + contextPath = "\(self.cwd)/\(buildConfig.context)" + } + // Build command arguments - var commands = ["\(self.cwd)/\(buildConfig.context)"] - + var commands = [contextPath] + // Add build arguments for (key, value) in buildConfig.args ?? [:] { commands.append(contentsOf: ["--build-arg", "\(key)=\(resolveVariable(value, with: environmentVariables))"]) } - - // Add Dockerfile path - commands.append(contentsOf: ["--file", "\(self.cwd)/\(buildConfig.dockerfile ?? "Dockerfile")"]) + + // Add Dockerfile path - should be relative to context, NOT cwd + let dockerfilePath = "\(contextPath)/\(buildConfig.dockerfile ?? "Dockerfile")" + commands.append(contentsOf: ["--file", dockerfilePath]) // Add caching options if noCache { From 34b8e4627e9ae41fec53ddffe5c1bc58af71b865 Mon Sep 17 00:00:00 2001 From: rtoohil Date: Mon, 1 Dec 2025 13:50:53 -0500 Subject: [PATCH 2/2] Changes to properly handle expanding the tilde character --- Sources/Container-Compose/Commands/ComposeUp.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Container-Compose/Commands/ComposeUp.swift b/Sources/Container-Compose/Commands/ComposeUp.swift index 42d4d6f..aa23987 100644 --- a/Sources/Container-Compose/Commands/ComposeUp.swift +++ b/Sources/Container-Compose/Commands/ComposeUp.swift @@ -598,10 +598,12 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable { return imageToRun } - // Resolve context path (handle absolute paths) + // Resolve context path (handle absolute paths and tilde expansion) let contextPath: String - if buildConfig.context.hasPrefix("/") || buildConfig.context.hasPrefix("~") { + if buildConfig.context.hasPrefix("/") { contextPath = buildConfig.context + } else if buildConfig.context.hasPrefix("~") { + contextPath = NSString(string: buildConfig.context).expandingTildeInPath } else { contextPath = "\(self.cwd)/\(buildConfig.context)" }