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

feat: allow custom build context to be configured when using DOCKERFILE_PATH #139

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

dannykopping
Copy link
Contributor

Fixes #129

Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
},
{
// Dockerfile & build context are not in the same dir, but inclFile is in the default build context dir;
// this should allow inclFile to be copied. This is probably not desirable though?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reviewer: should we warn when a Dockerfile is used outside the WorkspaceFolder, because the build context will likely be wrong?

Copy link
Member

Choose a reason for hiding this comment

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

You could also make an argument for failing the build entirely; but I think warning is fine here.

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

LGTM, just one question.

@@ -476,7 +480,7 @@ func Run(ctx context.Context, options Options) error {
buildParams = &devcontainer.Compiled{
DockerfilePath: dockerfilePath,
DockerfileContent: string(content),
BuildContext: options.WorkspaceFolder,
BuildContext: filepath.Join(options.WorkspaceFolder, options.BuildContextPath),
Copy link
Member

Choose a reason for hiding this comment

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

Since WorkspaceFolder is optional, what's the end-result if it's not provided, will this be correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WorkspaceFolder will be given a default value if none is provided:

envbuilder/envbuilder.go

Lines 270 to 276 in 0643d17

if options.WorkspaceFolder == "" {
var err error
options.WorkspaceFolder, err = DefaultWorkspaceFolder(options.GitURL)
if err != nil {
return err
}
}

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Awesome!

Signed-off-by: Danny Kopping <[email protected]>
@dannykopping dannykopping merged commit 9685dcc into main Apr 24, 2024
2 checks passed
@dannykopping dannykopping deleted the dk/dockerfile-path branch April 24, 2024 12:34
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.

Option to specify build path for Dockerfile
4 participants