Skip to content

Conversation

@wpjunior
Copy link
Member

@wpjunior wpjunior commented Dec 22, 2025

Sometimes users forget do add this ugly line:

ADD tsuru.yaml /

my suggestion is to auto identify tsuru.yaml from context when user use:

tsuru app deploy -a APP --dockerfile .

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds functionality to extract tsuru.yaml from the Docker build context when it's not present in the container filesystem. This provides a fallback mechanism for containerfile-based builds to access Tsuru configuration files from the build context.

Key changes:

  • New findAndReadTsuruYaml function to search for and read tsuru.yaml files from the build context directory
  • Integration in buildFromContainerFile to use context-based tsuru.yaml when not found in the built container image
  • Test case demonstrating the extraction behavior with testdata files

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/build/buildkit/build.go Adds findAndReadTsuruYaml function and integrates tsuru.yaml extraction from context as a fallback in buildFromContainerFile
pkg/build/buildkit/build_test.go Adds test case verifying tsuru.yaml extraction from context when not present in container filesystem
pkg/build/buildkit/testdata/tsuru-files-from-context/Dockerfile Test fixture with minimal Dockerfile that doesn't copy config files to container
pkg/build/buildkit/testdata/tsuru-files-from-context/tsuru.yaml Test fixture containing sample tsuru.yaml configuration
pkg/build/buildkit/testdata/tsuru-files-from-context/Procfile Test fixture containing sample Procfile configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +484 to +492
if tc.TsuruYaml == "" {
tsuruYamlData, err := findAndReadTsuruYaml(tmpDir)
if err != nil {
return nil, err
}
if tsuruYamlData != "" {
tc.TsuruYaml = tsuruYamlData
}
}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The test data directory contains a Procfile, but the implementation only extracts tsuru.yaml from the context directory. Consider implementing similar fallback logic for Procfile extraction when it's not present in the container filesystem. The test case "Dockerfile w/ build context (adds tsuru.yaml and Procfile)" (line 649) shows that both files should be handled consistently when they exist in the build context.

Copilot uses AI. Check for mistakes.
appFiles, err := NewBuildKit(bc, BuildKitOptions{TempDir: t.TempDir()}).Build(context.TODO(), req, os.Stdout)
require.NoError(t, err)
assert.Equal(t, &pb.TsuruConfig{
Procfile: "",
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The test data includes a Procfile but the test expects an empty Procfile field. This is inconsistent with the presence of the Procfile in the testdata directory. Either the Procfile should be removed from the testdata if it's not intended to be extracted, or the expected value should be updated to match the Procfile content and the implementation should be enhanced to extract it from context (similar to how tsuru.yaml is extracted).

Copilot uses AI. Check for mistakes.
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.

1 participant