Skip to content

Commit 87d22cd

Browse files
committed
Fix edge-case bug path prefix check for watch & bind mounts
Signed-off-by: Matiboux <[email protected]>
1 parent ea07ba8 commit 87d22cd

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

pkg/compose/watch.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ func loadDevelopmentConfig(service types.ServiceConfig, project *types.Project)
353353

354354
func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool {
355355
for _, volume := range volumes {
356-
if volume.Bind != nil && strings.HasPrefix(watchPath, volume.Source) {
357-
return true
356+
if volume.Bind != nil {
357+
relPath, err := filepath.Rel(volume.Source, watchPath)
358+
if err == nil && !strings.HasPrefix(relPath, "..") {
359+
return true
360+
}
358361
}
359362
}
360363
return false

pkg/e2e/fixtures/watch/compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ services:
3737
RUN mkdir -p /app/config
3838
init: true
3939
command: sleep infinity
40+
volumes:
41+
- ./dat:/app/dat
42+
- ./data-logs:/app/data-logs
4043
develop: *x-dev
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
i am a wannabe cat
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[INFO] Server started successfully on port 8080

0 commit comments

Comments
 (0)