Skip to content

Commit 078df39

Browse files
committed
fix(docker-compose): exclude service volumes without source
1 parent 69e03e1 commit 078df39

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/sweet-lions-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@anymodel/docker-compose": patch
3+
---
4+
5+
Fix `ServiceVolume` without source

packages/docker-compose/src/manifests/Service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ export class Service {
114114
typeof v === "string" ? v : v.join(":")
115115
),
116116
}),
117+
...(this.spec.volumes && {
118+
volumes: this.spec.volumes.filter(
119+
(v) => typeof v === "string" || v.source !== false
120+
),
121+
}),
117122
...(this.spec.volumes_from && {
118123
volumes_from: this.spec.volumes_from.map(resolveName),
119124
}),

packages/docker-compose/src/manifests/ServiceVolume.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class ServiceVolume {
4242
}
4343
}
4444
toJSON() {
45-
return `${this.source}:${this.target}${this.readOnly ? `:ro` : ""}`;
45+
const source = resolveSource(this.source)
46+
return `${source}:${this.target}${this.readOnly ? `:ro` : ""}`;
4647
}
4748
}

0 commit comments

Comments
 (0)