@@ -53,6 +53,39 @@ class ServiceDependency(TypedDict, total=False):
5353 """Condition under which a dependency is considered satisfied."""
5454
5555
56+ class ServiceDeployResourceLimits (TypedDict , total = False ):
57+ """Resource limits for a service deployment."""
58+
59+ memory : str
60+ """Memory limit (e.g., '6G', '512M')."""
61+
62+ cpus : str
63+ """CPU limit (e.g., '0.5', '2')."""
64+
65+
66+ class ServiceDeployResources (TypedDict , total = False ):
67+ """Resource configuration for a service deployment."""
68+
69+ limits : ServiceDeployResourceLimits
70+ """Resource limits."""
71+
72+ reservations : ServiceDeployResourceLimits
73+ """Resource reservations."""
74+
75+
76+ class ServiceDeploy (TypedDict , total = False ):
77+ """Deployment configuration for a service."""
78+
79+ resources : ServiceDeployResources
80+ """Resource configuration."""
81+
82+ replicas : int
83+ """Number of container replicas to deploy."""
84+
85+ restart_policy : dict [str , Any ]
86+ """Restart policy configuration."""
87+
88+
5689class ServiceConfig (TypedDict , total = False ):
5790 """The definition of a service in Docker Compose.
5891
@@ -141,11 +174,8 @@ class ServiceConfig(TypedDict, total=False):
141174 TODO(benesch): this should use a nested TypedDict.
142175 """
143176
144- deploy : dict [str , dict [str , dict [str , str ]]]
145- """Additional deployment configuration, like resource limits.
146-
147- TODO(benesch): this should use a nested TypedDict.
148- """
177+ deploy : ServiceDeploy
178+ """Deployment configuration, including resource limits."""
149179
150180 ulimits : dict [str , Any ]
151181 """Override the default ulimits for a container."""
@@ -178,6 +208,9 @@ class ServiceConfig(TypedDict, total=False):
178208 user : str | None
179209 """The user for the container."""
180210
211+ cap_add : list [str ] | None
212+ """cap_add specifies additional container capabilities as strings."""
213+
181214
182215class Service :
183216 """A Docker Compose service in a `Composition`.
0 commit comments