diff --git a/bug-12236/.dockerignore b/bug-12236/.dockerignore new file mode 100644 index 00000000000..30b73440641 --- /dev/null +++ b/bug-12236/.dockerignore @@ -0,0 +1,4 @@ +# ignore everything by default +* +# add exceptions here +!dir1/ \ No newline at end of file diff --git a/bug-12236/Dockerfile b/bug-12236/Dockerfile new file mode 100644 index 00000000000..dc770dd9f3f --- /dev/null +++ b/bug-12236/Dockerfile @@ -0,0 +1,3 @@ +FROM alpine:latest +WORKDIR /app +ENTRYPOINT ["ls", "-la"] \ No newline at end of file diff --git a/bug-12236/compose.yml b/bug-12236/compose.yml new file mode 100644 index 00000000000..2490fb2c995 --- /dev/null +++ b/bug-12236/compose.yml @@ -0,0 +1,11 @@ +services: + alpine: + build: + context: . + dockerfile: Dockerfile + develop: + watch: + - action: sync+restart + x-initialSync: true + path: ./dir1 + target: /app/dir1 \ No newline at end of file diff --git a/bug-12236/dir1/foo.txt b/bug-12236/dir1/foo.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/pkg/compose/watch.go b/pkg/compose/watch.go index 15d2c44c45f..627a57846d1 100644 --- a/pkg/compose/watch.go +++ b/pkg/compose/watch.go @@ -621,7 +621,7 @@ func (s *composeService) initialSync(ctx context.Context, project *types.Project if err != nil { return err } - + logrus.Debugf("copying %d files for initial sync", len(pathsToCopy)) return syncer.Sync(ctx, service, pathsToCopy) } @@ -651,6 +651,7 @@ func (s *composeService) initialSyncFiles(ctx context.Context, project *types.Pr return nil } if shouldIgnore(filepath.Base(path), ignore) || checkIfPathAlreadyBindMounted(path, service.Volumes) { + logrus.Debugf("ignoring file %s", path) // By definition sync ignores bind mounted paths if d.IsDir() { // skip folder @@ -665,6 +666,7 @@ func (s *composeService) initialSyncFiles(ctx context.Context, project *types.Pr if !d.IsDir() { if info.ModTime().Before(timeImageCreated) { // skip file if it was modified before image creation + logrus.Debugf("skipping file %s; it was modified before image creation", path) return nil } rel, err := filepath.Rel(trigger.Path, path) diff --git a/pkg/watch/dockerignore.go b/pkg/watch/dockerignore.go index aea77e80737..bde6b667bd9 100644 --- a/pkg/watch/dockerignore.go +++ b/pkg/watch/dockerignore.go @@ -23,6 +23,8 @@ import ( "path/filepath" "strings" + "github.com/sirupsen/logrus" + "github.com/compose-spec/compose-go/v2/types" "github.com/docker/compose/v2/internal/paths" "github.com/moby/patternmatcher" @@ -83,7 +85,7 @@ func LoadDockerIgnore(build *types.BuildConfig) (*dockerPathMatcher, error) { return nil, err } defer func() { _ = f.Close() }() - + logrus.Debugf("Using .dockerignore file: %s", f.Name()) patterns, err := readDockerignorePatterns(f) if err != nil { return nil, err