Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

docker build using -f instead of implied default #471

Merged
merged 6 commits into from
May 11, 2020

Conversation

dakale
Copy link
Contributor

@dakale dakale commented May 7, 2020

This lets you specify image: './path/to/dockerfile.Dockerfile instead of requiring the filename to be just Dockerfile.

Passes the existing filename to build explicitly with -f but continues passing the directory containing the dockerfile to indicate the docker context, rather than assuming it will contain "Dockerfile" by default.

e.g. in an action you can now have (under image):

# action.yml
name: 'Hello World'
runs:
  using: 'docker'
  image: './anyNameIWant.Dockerfile'
...

@dakale dakale requested a review from TingluoHuang May 7, 2020 21:07
{
return await ExecuteDockerCommandAsync(context, "build", $"-t {tag} \"{dockerFile}\"", workingDirectory, context.CancellationToken);
return await ExecuteDockerCommandAsync(context, "build", $"-t {tag} -f \"{dockerFile}\" {dockerContext}", workingDirectory, context.CancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

do we need to quote {dockerContext}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably. It works either way with my samples but I think if theres a whitespace or maybe other weird characters in the path it could get split / not work without quotes so I added them

ExecutionContext,
ExecutionContext.GetGitHubContext("workspace"),
dockerFile,
Directory.GetParent(dockerFile).FullName, imageName);
Copy link
Member

Choose a reason for hiding this comment

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

imageName on the newline. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@TingluoHuang TingluoHuang merged commit 462b511 into master May 11, 2020
@TingluoHuang TingluoHuang deleted the dakale/action-dockerfile branch May 11, 2020 17:57
AdamOlech pushed a commit to antmicro/runner that referenced this pull request Jan 28, 2021
* pass -f to docker build

* Wrong place

* build path

* Also pass docker context path

* Tidy up format

* PR Feedback
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants