Skip to content

Commit b7dedb5

Browse files
include redis
1 parent 7f751a2 commit b7dedb5

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

src/pkg/cli/compose/fixup.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ func fixupRedisService(svccfg *composeTypes.ServiceConfig, provider client.Provi
311311
}
312312
term.Debugf("service %q: adding redis host port %d", svccfg.Name, port)
313313
svccfg.Ports = []composeTypes.ServicePortConfig{{Target: port, Mode: Mode_HOST, Protocol: Protocol_TCP}}
314+
} else {
315+
for i, port := range svccfg.Ports {
316+
if port.Mode == Mode_INGRESS || port.Mode == "" {
317+
svccfg.Ports[i].Mode = Mode_HOST
318+
svccfg.Ports[i].Published = "" // ignore published port in host mode
319+
svccfg.Ports[i].AppProtocol = "" // ignore app_protocol in host mode
320+
}
321+
}
314322
}
315323
return nil
316324
}

src/testdata/redis/compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ services:
1313
- target: 6379
1414
mode: host
1515

16+
short-ports:
17+
image: redis
18+
x-defang-redis:
19+
ports:
20+
- 6379:6379
21+
1622
no-ext:
1723
image: redis
1824
ports:

src/testdata/redis/compose.yaml.fixup

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@
4747
}
4848
]
4949
},
50+
"short-ports": {
51+
"command": null,
52+
"entrypoint": null,
53+
"image": "redis",
54+
"networks": {
55+
"default": null
56+
},
57+
"ports": [
58+
{
59+
"mode": "host",
60+
"target": 6379,
61+
"protocol": "tcp"
62+
}
63+
]
64+
},
5065
"with-ext": {
5166
"command": null,
5267
"entrypoint": null,

src/testdata/redis/compose.yaml.golden

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ services:
2121
networks:
2222
default: null
2323
x-defang-redis: null
24+
short-ports:
25+
image: redis
26+
networks:
27+
default: null
28+
ports:
29+
- mode: ingress
30+
target: 6379
31+
published: "6379"
32+
protocol: tcp
33+
x-defang-redis: null
2434
with-ext:
2535
image: redis
2636
networks:

src/testdata/redis/compose.yaml.warnings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
! service "no-ext": stateful service will lose data on restart; use a managed service instead
33
! service "no-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
44
! service "no-ports-override": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
5+
! service "short-ports": ingress port without healthcheck defaults to GET / HTTP/1.1
6+
! service "short-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
57
! service "with-ext": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
68
! service "wrong-image": managed Redis service should use a redis image
79
! service "wrong-image": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors

0 commit comments

Comments
 (0)