Skip to content

Fix container build not using context-dir Dockerfile by default#793

Closed
0xEDU wants to merge 6 commits intoapple:mainfrom
0xEDU:build-context-proposal
Closed

Fix container build not using context-dir Dockerfile by default#793
0xEDU wants to merge 6 commits intoapple:mainfrom
0xEDU:build-context-proposal

Conversation

@0xEDU
Copy link

@0xEDU 0xEDU commented Oct 21, 2025

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

This PR proposes a solution that resolves #782.
If the -f flag is not provided, I prepend the context directory before the filename so that it matches Docker’s behavior and uses the Dockerfile in the context directory.
I also added tests for this behavior.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Copy link

@mdempsky mdempsky Oct 21, 2025

Choose a reason for hiding this comment

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

I believe docker build -f Dockerfile dir uses ./Dockerfile, not dir/Dockerfile.

I think to match that behavior, you'll have to change the flag behavior so you can distinguish no -f flag from an explicit -f Dockerfile.

Maybe change it to an optional string, and use contextDir + "/Dockerfile" as the default with it's absent.

And then two style suggestions:

  1. Maybe add a helper method or getter so you don't need to duplicate this logic elsewhere.

  2. Is string concatenation with "/" the right way to join paths in swift? But maybe it doesn't matter since this is a macOS-specific app anyway.

@0xEDU 0xEDU force-pushed the build-context-proposal branch 2 times, most recently from 5358cd3 to 05d24e5 Compare October 21, 2025 22:44
@0xEDU 0xEDU force-pushed the build-context-proposal branch from 05d24e5 to 2dec790 Compare October 21, 2025 23:03
@0xEDU
Copy link
Author

0xEDU commented Oct 21, 2025

I’ve applied the requested changes and am open to any additional suggestions or adjustments (also had a little quarrel with Git, hence the force pushes 😅).

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this since it's not being used in the dockerfile

@0xEDU
Copy link
Author

0xEDU commented Oct 25, 2025

I've addressed the test changes and fixed the formatting issue!

@dcantah
Copy link
Member

dcantah commented Oct 27, 2025

I realized right before opening #812 that it fixes #782 as well 😅 my apologies. I should've remembered this was open

@0xEDU
Copy link
Author

0xEDU commented Oct 27, 2025

No problem at all! Supersede this if yours fully covers the same case, happy to adjust or close mine if needed 👍

@jglogan
Copy link
Contributor

jglogan commented Oct 27, 2025

@0xEDU I merged #812 but please have a look at yours and see if there's anything from it that might still be useful to integrate, otherwise yeah go ahead and close it. Thank you for contributing and sorry for the mixup!

@katiewasnothere
Copy link
Contributor

@0xEDU Closing since the other changes have been merged. Feel free to open another PR if there's additional content your PR made that was not included in the merged changes, especially the tests :)

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.

[Bug]: container build not using context-dir

5 participants

Comments