Skip to content

Fix explicit compose file path resolution#64

Open
ravshansbox wants to merge 2 commits intoMcrich23:mainfrom
ravshansbox:fix/compose-file-path-resolution
Open

Fix explicit compose file path resolution#64
ravshansbox wants to merge 2 commits intoMcrich23:mainfrom
ravshansbox:fix/compose-file-path-resolution

Conversation

@ravshansbox
Copy link
Contributor

@ravshansbox ravshansbox commented Mar 14, 2026

Summary

  • honor explicit -f/--file input instead of treating compose.yml as a sentinel
  • autodiscover standard compose filenames only when no file option was provided
  • resolve compose-relative env_file, build context, and Dockerfile paths from the compose file directory

Problem

The existing code always derived composePath from "\(cwd)/\(composeFilename)", which breaks absolute compose file paths and conflates default behavior with explicit user input.

Changes

  • change composeFilename from a magic default string to String? in ComposeUp and ComposeDown
  • add a shared resolvedPath(for:relativeTo:) helper
  • move compose autodiscovery into composePath and run it only when no explicit file was passed
  • resolve service env_file, build context, and Dockerfile paths relative to the compose file directory in ComposeUp

Verification

  • swift build
  • ./.build/debug/Container-Compose down -f /Users/user/projects/project/docker-compose.yml

Fixes #63

@Mcrich23
Copy link
Owner

The original intent of this flag was for it to be relative for those who want a different compose file in their folder. I totally see why this could be frustrating for someone who may want to use an absolute path instead.

Let me do some code review and we can move forward from there.

Copy link
Owner

@Mcrich23 Mcrich23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks pretty good, just a couple issues. Thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit -f compose paths are resolved incorrectly and user input is overridden

2 participants