Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix dockerfile local dir #1192

Merged
merged 1 commit into from
Jul 7, 2022
Merged

Conversation

junnplus
Copy link
Member

@junnplus junnplus commented Jul 5, 2022

Signed-off-by: Ye Sijun junnplus@gmail.com

Fixes: #1191

In addition, check in advance whether the dockerfile file exists.

before:

[N] ❯ sudo nerdctl build -t backstage:dev ..
[+] Building 0.0s (2/2) FINISHED
 => [internal] load .dockerignore                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                             0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                        0.0s
 => => transferring dockerfile: 2B                                                                                                                                                                                          0.0s
error: failed to solve: failed to read dockerfile: open /tmp/buildkit-mount1687483572/Dockerfile: no such file or directory
FATA[0000] unrecognized image format

after:

[N] ❯ sudo nerdctl build -t backstage:dev ..
FATA[0000] lstat /home/jun/Documents/workspace/my-backstage/packages/Dockerfile: no such file or directory

@junnplus junnplus force-pushed the build-dockerfile branch 3 times, most recently from 70cd2cd to 0bce666 Compare July 5, 2022 13:05
@junnplus junnplus requested review from fahedouch and AkihiroSuda July 5, 2022 13:48
func TestBuildWithDockerfile(t *testing.T) {
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
defer base.Cmd("builder", "prune").Run()
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Why do we need builder prune? Won't these slow our tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @ktock

Copy link
Member

Choose a reason for hiding this comment

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

@manugupt1 @junnplus This was to ensure all content (possibly leased by BuildKit) in the content store gets pruned after each test. Tests may check the behaviour of pulling blobs and contents remaining in the content store unexpectedly skip these operations.But yes, we may improve this by removing defer base.Cmd("builder", "prune").Run() and instead adding rmiAll() (defined in image_encrypt_linux_test.go) to tests (if exist) requiring clean content store. Thanks for pointing this out :)

Copy link
Contributor

@manugupt1 manugupt1 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 the changes!

Copy link
Member

@Zheaoli Zheaoli left a comment

Choose a reason for hiding this comment

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

LGTM

assert.NilError(t, err)
defer os.Chdir(pwd)

// hack os.Getwd return "(unreachable)" on rootless
Copy link
Member

Choose a reason for hiding this comment

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

How does this happen?

Can't find "unreachable" error in the code
https://cs.opensource.google/go/go/+/refs/tags/go1.18.3:src/os/getwd.go;l=22

Copy link
Member Author

@junnplus junnplus Jul 6, 2022

Choose a reason for hiding this comment

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

I actually don't know what happened, Getwd returns a strange path during rootless testing.
(unreachable)/tmp/TestBuildWithDockerfile2096791215/001/text/Dockerfile

https://github.com/containerd/nerdctl/runs/7196804919?check_suite_focus=true#step:5:1004

@junnplus junnplus added this to the v0.22.0 milestone Jul 6, 2022
Signed-off-by: Ye Sijun <junnplus@gmail.com>
@junnplus junnplus force-pushed the build-dockerfile branch from 0bce666 to eb3715a Compare July 6, 2022 16:29
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit b1ae460 into containerd:master Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants