Skip to content

fix(docker): Fix failing end to end tests#997

Merged
mergify[bot] merged 2 commits intoaws:masterfrom
bvtujo:fix-e2e
Jun 6, 2020
Merged

fix(docker): Fix failing end to end tests#997
mergify[bot] merged 2 commits intoaws:masterfrom
bvtujo:fix-e2e

Conversation

@bvtujo
Copy link
Copy Markdown
Contributor

@bvtujo bvtujo commented Jun 6, 2020

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:

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:

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:

docker build -t <imageTag> path/to -f path/to/dockerfile

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

bvtujo added 2 commits June 4, 2020 16:13
This PR resolves an issue in the construciton of the call to `docker
build` which resulted in the following syntax for a dockerfile at the
location `path/to/dockerfile`:

```
docker build -t <image-tag> path/to/ -f dockerfile
```

The trailing slash causes the end to end tests to fail to find a
dockerfile at the specific location.
@bvtujo bvtujo requested a review from a team as a code owner June 6, 2020 00:03
@bvtujo bvtujo requested a review from kohidave June 6, 2020 00:03
@bvtujo
Copy link
Copy Markdown
Contributor Author

bvtujo commented Jun 6, 2020

manual e2e output:

------------------------------
addons flow when deploying svc
  svc deploy should succeed
  /github.com/aws/amazon-ecs-cli-v2/e2e/addons/addons_test.go:145
Sending build context to Docker daemon  15.36kB
Step 1/12 : FROM golang:1.13 AS builder
1.13: Pulling from library/golang
376057ac6fa1: Pulling fs layer
5a63a0a859d8: Pulling fs layer
496548a8c952: Pulling fs layer
2adae3950d4d: Pulling fs layer
039b991354af: Pulling fs layer
036abadca78f: Pulling fs layer
0514917ef7dc: Pulling fs layer
039b991354af: Waiting
036abadca78f: Waiting
0514917ef7dc: Waiting
2adae3950d4d: Waiting
5a63a0a859d8: Verifying Checksum
5a63a0a859d8: Download complete
496548a8c952: Verifying Checksum
496548a8c952: Download complete
376057ac6fa1: Verifying Checksum
376057ac6fa1: Download complete
376057ac6fa1: Pull complete
5a63a0a859d8: Pull complete
496548a8c952: Pull complete
2adae3950d4d: Verifying Checksum
2adae3950d4d: Download complete
0514917ef7dc: Verifying Checksum
0514917ef7dc: Download complete
2adae3950d4d: Pull complete
039b991354af: Verifying Checksum
039b991354af: Download complete
039b991354af: Pull complete
036abadca78f: Verifying Checksum
036abadca78f: Download complete
036abadca78f: Pull complete
0514917ef7dc: Pull complete
Digest: sha256:c56dbb28a169f9bccdf398dc9d4bc8d41463352843dbcf03b6ef2fb3472c1794
Status: Downloaded newer image for golang:1.13
 ---> 84125009cb55
Step 2/12 : RUN mkdir /app
 ---> Running in 2c23f121b950
Removing intermediate container 2c23f121b950
 ---> 34b4e6a32ba5
Step 3/12 : ADD . /app
 ---> 31c256dafe5e
Step 4/12 : WORKDIR /app
 ---> Running in 2e559aa8da0f
Removing intermediate container 2e559aa8da0f
 ---> 1b43d13a1e12
Step 5/12 : ENV GOPROXY=direct
 ---> Running in e79f955cd745
Removing intermediate container e79f955cd745
 ---> e668b8a2d405
Step 6/12 : RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64  go build -o api ./
 ---> Running in 32730af8f89d
go: downloading github.com/julienschmidt/httprouter v1.3.0
go: downloading github.com/aws/aws-sdk-go v1.29.22
go: extracting github.com/julienschmidt/httprouter v1.3.0
go: extracting github.com/aws/aws-sdk-go v1.29.22
go: downloading github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
go: extracting github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
go: finding github.com/aws/aws-sdk-go v1.29.22
go: finding github.com/julienschmidt/httprouter v1.3.0
go: finding github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
Removing intermediate container 32730af8f89d
 ---> 787aa8f4f6ff
Step 7/12 : FROM alpine:latest
latest: Pulling from library/alpine
df20fa9351a1: Pulling fs layer
df20fa9351a1: Verifying Checksum
df20fa9351a1: Download complete
df20fa9351a1: Pull complete
Digest: sha256:185518070891758909c9f839cf4ca393ee977ac378609f700f60a771a2dfe321
Status: Downloaded newer image for alpine:latest
 ---> a24bb4013296
Step 8/12 : RUN apk --no-cache add ca-certificates
 ---> Running in 6a54d8147616
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/1) Installing ca-certificates (20191127-r3)
Executing busybox-1.31.1-r16.trigger
Executing ca-certificates-20191127-r3.trigger
OK: 6 MiB in 15 packages
Removing intermediate container 6a54d8147616
 ---> 143949a73174
Step 9/12 : COPY --from=builder /app ./
 ---> d733f8c7298e
Step 10/12 : RUN chmod +x ./api
 ---> Running in d4aa4244d5eb
Removing intermediate container d4aa4244d5eb
 ---> 27b12afc23a8
Step 11/12 : ENTRYPOINT ["./api"]
 ---> Running in e2ae51273668
Removing intermediate container e2ae51273668
 ---> ed0aea306c5b
Step 12/12 : EXPOSE 80
 ---> Running in 56e0483299d6
Removing intermediate container 56e0483299d6
 ---> 23762d06ee5c
Successfully built 23762d06ee5c
Successfully tagged 898620229039.dkr.ecr.us-west-2.amazonaws.com/e2e-addons-1591399928/hello:gallopinggurdey
WARNING! Your password will be stored unencrypted in /home/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
The push refers to repository [898620229039.dkr.ecr.us-west-2.amazonaws.com/e2e-addons-1591399928/hello]
c90a228106bd: Preparing
a179a9585d82: Preparing
0240e72df335: Preparing
50644c29ef5a: Preparing
50644c29ef5a: Pushed
c90a228106bd: Pushed
a179a9585d82: Pushed
0240e72df335: Pushed
gallopinggurdey: digest: sha256:6336b47e054d7f6f72a7ed0b0f5e7f6536b9d4365340a9346c4ccf09243abae5 size: 1160


✔ Deployed hello, you can access it at http://e2e-a-Publi-NDYHD1Y9WIY7-993455.us-west-2.elb.amazonaws.com.

• [SLOW TEST:447.251 seconds]
addons flow
/github.com/aws/amazon-ecs-cli-v2/e2e/addons/addons_test.go:19
  when deploying svc
  /github.com/aws/amazon-ecs-cli-v2/e2e/addons/addons_test.go:133
    svc deploy should succeed
    /github.com/aws/amazon-ecs-cli-v2/e2e/addons/addons_test.go:145

@bvtujo bvtujo changed the title bug(docker): Fix failing end to end tests fix(docker): Fix failing end to end tests Jun 6, 2020
Copy link
Copy Markdown
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@huanjani
Copy link
Copy Markdown
Contributor

huanjani commented Jun 6, 2020

Thanks for the thorough explanation!

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.

4 participants