GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(docker): docker build failed when multiple Dockerfile in one dir by iamhopaul123 · Pull Request #980 · aws/copilot-cli

This repository was archived by the owner on Jun 22, 2026. It is now read-only.

Conversation

@iamhopaul123

@iamhopaul123 iamhopaul123 commented May 29, 2020

Copy link
Copy Markdown
Contributor

Fix #979

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iamhopaul123
iamhopaul123 requested review from a team, Louise15926, SoManyHs, bvtujo, efekarakus, huanjani, kohidave and seongm-1 May 29, 2020 22:18
kohidave
kohidave reviewed May 29, 2020
View reviewed changes

@kohidave kohidave left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for your super quick turn around!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread internal/pkg/docker/docker.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@iamhopaul123
iamhopaul123 force-pushed the docker/bug-fix branch 2 times, most recently from fb299fb to 77439cb Compare May 30, 2020 19:33
@efekarakus efekarakus added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jun 1, 2020
efekarakus
efekarakus approved these changes Jun 1, 2020
View reviewed changes
Comment thread internal/pkg/docker/docker.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread internal/pkg/docker/docker.go
dfPath, dfName := filepath.Split(path)

err := s.runner.Run("docker", []string{"build", "-t", imageName, path})
err := r.Run("docker", []string{"build", "-t", imageName, dfPath, "-f", dfName})

@efekarakus efekarakus Jun 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

awesome tyty 🙏

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iamhopaul123
fix(docker): docker build failed when multiple Dockerfile in one dir
5bf3823
@iamhopaul123
iamhopaul123 force-pushed the docker/bug-fix branch from 77439cb to 5bf3823 Compare June 1, 2020 21:41
@iamhopaul123 iamhopaul123 removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jun 1, 2020
kohidave
kohidave approved these changes Jun 1, 2020
View reviewed changes
@mergify
mergify Bot merged commit ce5d2d9 into aws:master Jun 1, 2020
@bvtujo bvtujo mentioned this pull request Jun 6, 2020
fix(docker): Fix failing end to end tests #997
Merged
mergify Bot pushed a commit that referenced this pull request Jun 6, 2020
@bvtujo
fix(docker): Fix failing end to end tests (#997)
ed3127e
<!-- Provide summary of changes -->
With #980, we fixed an issue which occurred when there were multiple dockerfiles present in the build directory. 

However, this may have broken our end to end tests, because the call to Docker was formatted as the following:

```sh
docker build -t <imageTag> path/to -f Dockerfile
```

This should be fine, but the end to end tests began to fail on Monday with the following output:
```bash
addons flow when deploying svc
  svc deploy should succeed
  /github.com/aws/amazon-ecs-cli-v2/e2e/addons/addons_test.go:145
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /github.com/aws/amazon-ecs-cli-v2/e2e/addons/Dockerfile: no such file or directory
Error: build Dockerfile at ./hello/Dockerfile with tag gallopinggurdey: building image: exit status 1
```
This indicates that although the Dockerfile path was set to `hello/Dockerfile`, Docker was looking for the file somewhere in the root directory of that path (.) and subsequently failing. 

This fix always sets the dockerfile path to be relative to the *root* of the docker build context, not the *leaf* of the build context. 

(previously we were parsing paths like `path/to/dockerfile` into `path/to` and `dockerfile`, assuming that the dockerfile would be searched for in `path/to`, not `path`. This was incorrect.)

The new behavior is to call:
```sh
docker build -t <imageTag> path/to -f path/to/dockerfile
```



<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
@bvtujo bvtujo mentioned this pull request Jun 8, 2020
internal/pkg/docker should be more flexible with context and dockerfile paths #822
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@Louise15926 Louise15926 Awaiting requested review from Louise15926
@bvtujo bvtujo Awaiting requested review from bvtujo
@SoManyHs SoManyHs Awaiting requested review from SoManyHs
@seongm-1 seongm-1 Awaiting requested review from seongm-1
@huanjani huanjani Awaiting requested review from huanjani
2 more reviewers
@kohidave kohidave kohidave approved these changes
@efekarakus efekarakus efekarakus approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Only accepts dockerfile named Dockerfile

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@iamhopaul123 @kohidave @efekarakus
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.