cue.dev/x/dockercompose@v0.5.0

schema.cue raw

   1package dockercompose
   2
   3import "list"
   4
   5// Compose Specification
   6//
   7// The Compose file is a YAML file defining a multi-containers based application.
   8#Schema: {
   9	@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
  10	@jsonschema(id="https://raw.githubusercontent.com/compose-spec/compose-spec/HEAD/schema/compose_spec.json")
  11	close({
  12		// declared for backward compatibility, ignored. Please remove it.
  13		"version"?: string @deprecated()
  14
  15		// define the Compose project name, until user defines one explicitly.
  16		"name"?: string
  17
  18		// compose sub-projects to be included.
  19		"include"?: [...#include]
  20
  21		// The services that will be used by your application.
  22		"services"?: close({
  23
  24			{[=~"^[a-zA-Z0-9._-]+$"]: #service}})
  25
  26		// Language models that will be used by your application.
  27		"models"?: {
  28			{[=~"^[a-zA-Z0-9._-]+$"]: #model}
  29			...
  30		}
  31
  32		// Networks that are shared among multiple services.
  33		"networks"?: {
  34			{[=~"^[a-zA-Z0-9._-]+$"]: #network}
  35			...
  36		}
  37
  38		// Named volumes that are shared among multiple services.
  39		"volumes"?: close({
  40
  41			{[=~"^[a-zA-Z0-9._-]+$"]: #volume}})
  42
  43		// Secrets that are shared among multiple services.
  44		"secrets"?: close({
  45
  46			{[=~"^[a-zA-Z0-9._-]+$"]: #secret}})
  47
  48		// Configurations that are shared among multiple services.
  49		"configs"?: close({
  50
  51			{[=~"^[a-zA-Z0-9._-]+$"]: #config}})
  52
  53		{[=~"^x-"]: _}
  54	})
  55
  56	// Block IO limit for a specific device.
  57	#blkio_limit: close({
  58		// Path to the device (e.g., '/dev/sda').
  59		"path"?: string
  60
  61		// Rate limit in bytes per second or IO operations per second.
  62		"rate"?: int | string
  63	})
  64
  65	// Block IO weight for a specific device.
  66	#blkio_weight: close({
  67		// Path to the device (e.g., '/dev/sda').
  68		"path"?: string
  69
  70		// Relative weight for the device, between 10 and 1000.
  71		"weight"?: int | string
  72	})
  73
  74	// Command to run in the container, which can be specified as a string (shell
  75	// form) or array (exec form).
  76	#command: matchN(1, [null, string, [...string]])
  77
  78	// Config configuration for the Compose application.
  79	#config: close({
  80		// Custom name for this config.
  81		"name"?: string
  82
  83		// Inline content of the config.
  84		"content"?: string
  85
  86		// Name of an environment variable from which to get the config value.
  87		"environment"?: string
  88
  89		// Path to a file containing the config value.
  90		"file"?: string
  91
  92		// Specifies that this config already exists and was created outside of Compose.
  93		"external"?: bool | string | {
  94			// Specifies the name of the external config. Deprecated: use the 'name' property instead.
  95			"name"?: string @deprecated()
  96			...
  97		}
  98
  99		// Add metadata to the config using labels.
 100		"labels"?: #list_or_dict
 101
 102		// Driver to use for templating the config's value.
 103		"template_driver"?: string
 104
 105		{[=~"^x-"]: _}
 106	})
 107
 108	// Deployment configuration for the service.
 109	#deployment: null | close({
 110		// Deployment mode for the service: 'replicated' (default) or 'global'.
 111		"mode"?: string
 112
 113		// Endpoint mode for the service: 'vip' (default) or 'dnsrr'.
 114		"endpoint_mode"?: string
 115
 116		// Number of replicas of the service container to run.
 117		"replicas"?: int | string
 118
 119		// Labels to apply to the service.
 120		"labels"?: #list_or_dict
 121
 122		// Configuration for rolling back a service update.
 123		"rollback_config"?: close({
 124			// The number of containers to rollback at a time. If set to 0, all containers
 125			// rollback simultaneously.
 126			"parallelism"?: int | string
 127
 128			// The time to wait between each container group's rollback (e.g., '1s', '1m30s').
 129			"delay"?: string
 130
 131			// Action to take if a rollback fails: 'continue', 'pause'.
 132			"failure_action"?: string
 133
 134			// Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s').
 135			"monitor"?: string
 136
 137			// Failure rate to tolerate during a rollback.
 138			"max_failure_ratio"?: number | string
 139
 140			// Order of operations during rollbacks: 'stop-first' (default) or 'start-first'.
 141			"order"?: "start-first" | "stop-first"
 142
 143			{[=~"^x-"]: _}
 144		})
 145
 146		// Configuration for updating a service.
 147		"update_config"?: close({
 148			// The number of containers to update at a time.
 149			"parallelism"?: int | string
 150
 151			// The time to wait between updating a group of containers (e.g., '1s', '1m30s').
 152			"delay"?: string
 153
 154			// Action to take if an update fails: 'continue', 'pause', 'rollback'.
 155			"failure_action"?: string
 156
 157			// Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s').
 158			"monitor"?: string
 159
 160			// Failure rate to tolerate during an update (0 to 1).
 161			"max_failure_ratio"?: number | string
 162
 163			// Order of operations during updates: 'stop-first' (default) or 'start-first'.
 164			"order"?: "start-first" | "stop-first"
 165
 166			{[=~"^x-"]: _}
 167		})
 168
 169		// Resource constraints and reservations for the service.
 170		"resources"?: close({
 171			// Resource limits for the service containers.
 172			"limits"?: close({
 173				// Limit for how much of the available CPU resources, as number of cores, a container can use.
 174				"cpus"?: number | string
 175
 176				// Limit on the amount of memory a container can allocate (e.g., '1g', '1024m').
 177				"memory"?: string
 178
 179				// Maximum number of PIDs available to the container.
 180				"pids"?: int | string
 181
 182				{[=~"^x-"]: _}
 183			})
 184
 185			// Resource reservations for the service containers.
 186			"reservations"?: close({
 187				// Reservation for how much of the available CPU resources, as number of cores, a container can use.
 188				"cpus"?: number | string
 189
 190				// Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m').
 191				"memory"?: string
 192
 193				// User-defined resources to reserve.
 194				"generic_resources"?: #generic_resources
 195
 196				// Device reservations for the container.
 197				"devices"?: #devices
 198
 199				{[=~"^x-"]: _}
 200			})
 201
 202			{[=~"^x-"]: _}
 203		})
 204
 205		// Restart policy for the service containers.
 206		"restart_policy"?: close({
 207			// Condition for restarting the container: 'none', 'on-failure', 'any'.
 208			"condition"?: string
 209
 210			// Delay between restart attempts (e.g., '1s', '1m30s').
 211			"delay"?: string
 212
 213			// Maximum number of restart attempts before giving up.
 214			"max_attempts"?: int | string
 215
 216			// Time window used to evaluate the restart policy (e.g., '1s', '1m30s').
 217			"window"?: string
 218
 219			{[=~"^x-"]: _}
 220		})
 221
 222		// Constraints and preferences for the platform to select a physical node to run service containers
 223		"placement"?: close({
 224			// Placement constraints for the service (e.g., 'node.role==manager').
 225			"constraints"?: [...string]
 226
 227			// Placement preferences for the service.
 228			"preferences"?: [...close({
 229				// Spread tasks evenly across values of the specified node label.
 230				"spread"?: string
 231
 232				{[=~"^x-"]: _}
 233			})]
 234
 235			// Maximum number of replicas of the service.
 236			"max_replicas_per_node"?: int | string
 237
 238			{[=~"^x-"]: _}
 239		})
 240
 241		{[=~"^x-"]: _}
 242	})
 243
 244	// Development configuration for the service, used for development workflows.
 245	#development: null | close({
 246		// Configure watch mode for the service, which monitors file changes and
 247		// performs actions in response.
 248		"watch"?: [...close({
 249			// Patterns to exclude from watching.
 250			"ignore"?: #string_or_list
 251
 252			// Patterns to include in watching.
 253			"include"?: #string_or_list
 254
 255			// Path to watch for changes.
 256			"path"!: string
 257
 258			// Action to take when a change is detected: rebuild the container, sync files,
 259			// restart the container, sync and restart, or sync and execute a command.
 260			"action"!: "rebuild" | "sync" | "restart" | "sync+restart" | "sync+exec"
 261
 262			// Target path in the container for sync operations.
 263			"target"?: string
 264
 265			// Command to execute when a change is detected and action is sync+exec.
 266			"exec"?: #service_hook
 267
 268			// Ensure that an initial synchronization is done before starting watch mode for sync+x triggers
 269			"initial_sync"?: bool
 270
 271			{[=~"^x-"]: _}
 272		})]
 273
 274		{[=~"^x-"]: _}
 275	})
 276
 277	// Device reservations for containers, allowing services to access specific hardware devices.
 278	#devices: [...close({
 279		// List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility').
 280		"capabilities"!: #list_of_strings
 281
 282		// Number of devices of this type to reserve.
 283		"count"?: int | string
 284
 285		// List of specific device IDs to reserve.
 286		"device_ids"?: #list_of_strings
 287
 288		// Device driver to use (e.g., 'nvidia').
 289		"driver"?: string
 290
 291		// Driver-specific options for the device.
 292		"options"?: #list_or_dict
 293
 294		{[=~"^x-"]: _}
 295	})]
 296
 297	#env_file: matchN(1, [
 298		string,
 299		[...matchN(1, [
 300			string,
 301			close({
 302				// Path to the environment file.
 303				"path"!: string
 304
 305				// Format attribute lets you to use an alternative file formats for env_file.
 306				// When not set, env_file is parsed according to Compose rules.
 307				"format"?: string
 308
 309				// Whether the file is required. If true and the file doesn't exist, an error will be raised.
 310				"required"?: bool | string
 311			})
 312		])]
 313	])
 314
 315	// Additional hostnames to be defined in the container's /etc/hosts file.
 316	#extra_hosts: matchN(1, [
 317		close({
 318
 319			{[=~".+"]: matchN(1, [string, [...string]])}}),
 320		list.UniqueItems() & [...string]
 321	])
 322
 323	// User-defined resources for services, allowing services to reserve specialized hardware resources.
 324	#generic_resources: [...close({
 325		// Specification for discrete (countable) resources.
 326		"discrete_resource_spec"?: close({
 327			// Type of resource (e.g., 'GPU', 'FPGA', 'SSD').
 328			"kind"?: string
 329
 330			// Number of resources of this kind to reserve.
 331			"value"?: number | string
 332
 333			{[=~"^x-"]: _}
 334		})
 335
 336		{[=~"^x-"]: _}
 337	})]
 338
 339	#gpus: matchN(1, [
 340		"all",
 341		[...{
 342			// List of capabilities the GPU needs to have (e.g., 'compute', 'utility').
 343			"capabilities"?: #list_of_strings
 344
 345			// Number of GPUs to use.
 346			"count"?: int | string
 347
 348			// List of specific GPU device IDs to use.
 349			"device_ids"?: #list_of_strings
 350
 351			// GPU driver to use (e.g., 'nvidia').
 352			"driver"?: string
 353
 354			// Driver-specific options for the GPU.
 355			"options"?: #list_or_dict
 356			...
 357		}]
 358	])
 359
 360	// Configuration options to determine whether the container is healthy.
 361	#healthcheck: close({
 362		// Disable any container-specified healthcheck. Set to true to disable.
 363		"disable"?: bool | string
 364
 365		// Time between running the check (e.g., '1s', '1m30s'). Default: 30s.
 366		"interval"?: string
 367
 368		// Number of consecutive failures needed to consider the container as unhealthy. Default: 3.
 369		"retries"?: number | string
 370
 371		// The test to perform to check container health. Can be a string or a list. The
 372		// first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the
 373		// command is exec'd. If it's CMD-SHELL, the rest is run in the shell.
 374		"test"?: matchN(1, [string, [...string]])
 375
 376		// Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s.
 377		"timeout"?: string
 378
 379		// Start period for the container to initialize before starting health-retries
 380		// countdown (e.g., '1s', '1m30s'). Default: 0s.
 381		"start_period"?: string
 382
 383		// Time between running the check during the start period (e.g., '1s', '1m30s').
 384		// Default: interval value.
 385		"start_interval"?: string
 386
 387		{[=~"^x-"]: _}
 388	})
 389
 390	// Compose application or sub-projects to be included.
 391	#include: matchN(1, [
 392		string,
 393		close({
 394			// Path to the Compose application or sub-project files to include.
 395			"path"?: #string_or_list
 396
 397			// Path to the environment files to use to define default values when
 398			// interpolating variables in the Compose files being parsed.
 399			"env_file"?: #string_or_list
 400
 401			// Path to resolve relative paths set in the Compose file
 402			"project_directory"?: string
 403		})
 404	])
 405
 406	#label_file: matchN(1, [string, [...string]])
 407
 408	// A list of unique string values.
 409	#list_of_strings: list.UniqueItems() & [...string]
 410
 411	// Either a dictionary mapping keys to values, or a list of strings.
 412	#list_or_dict: matchN(1, [
 413		close({
 414
 415			{[=~".+"]: null | bool | number | string}}),
 416		list.UniqueItems() & [...string]
 417	])
 418
 419	// Language Model for the Compose application.
 420	#model: close({
 421		// Custom name for this model.
 422		"name"?: string
 423
 424		// Language Model to run.
 425		"model"!:        string
 426		"context_size"?: int
 427
 428		// Raw runtime flags to pass to the inference engine.
 429		"runtime_flags"?: [...string]
 430
 431		{[=~"^x-"]: _}
 432	})
 433
 434	// Network configuration for the Compose application.
 435	#network: null | close({
 436		// Custom name for this network.
 437		"name"?: string
 438
 439		// Specify which driver should be used for this network. Default is 'bridge'.
 440		"driver"?: string
 441
 442		// Specify driver-specific options defined as key/value pairs.
 443		"driver_opts"?: {
 444			{[=~"^.+$"]: number | string}
 445			...
 446		}
 447
 448		// Custom IP Address Management configuration for this network.
 449		"ipam"?: close({
 450			// Custom IPAM driver, instead of the default.
 451			"driver"?: string
 452
 453			// List of IPAM configuration blocks.
 454			"config"?: [...close({
 455				// Subnet in CIDR format that represents a network segment.
 456				"subnet"?: string
 457
 458				// Range of IPs from which to allocate container IPs.
 459				"ip_range"?: string
 460
 461				// IPv4 or IPv6 gateway for the subnet.
 462				"gateway"?: string
 463
 464				// Auxiliary IPv4 or IPv6 addresses used by Network driver.
 465				"aux_addresses"?: close({
 466
 467					{[=~"^.+$"]: string}})
 468
 469				{[=~"^x-"]: _}
 470			})]
 471
 472			// Driver-specific options for the IPAM driver.
 473			"options"?: close({
 474
 475				{[=~"^.+$"]: string}})
 476
 477			{[=~"^x-"]: _}
 478		})
 479
 480		// Specifies that this network already exists and was created outside of Compose.
 481		"external"?: bool |
 482		string |
 483		close({
 484			// Specifies the name of the external network. Deprecated: use the 'name' property instead.
 485			"name"?: string @deprecated()
 486
 487			{[=~"^x-"]: _}
 488		})
 489
 490		// Create an externally isolated network.
 491		"internal"?: bool | string
 492
 493		// Enable IPv4 networking.
 494		"enable_ipv4"?: bool | string
 495
 496		// Enable IPv6 networking.
 497		"enable_ipv6"?: bool | string
 498
 499		// If true, standalone containers can attach to this network.
 500		"attachable"?: bool | string
 501
 502		// Add metadata to the network using labels.
 503		"labels"?: #list_or_dict
 504
 505		{[=~"^x-"]: _}
 506	})
 507
 508	// Configuration for a pre_start init container, run to completion before the
 509	// service container starts.
 510	#pre_start_hook: close({
 511		// Command to execute. Optional when the chosen image's entrypoint already runs
 512		// the intended command.
 513		"command"?: #command
 514
 515		// Image used for the ephemeral container. If omitted, the parent service's image is used.
 516		"image"?: string
 517
 518		// User to run the command as. Defaults to the user declared in image (or to the
 519		// service's user when image is omitted).
 520		"user"?: string
 521
 522		// Whether to run the command with extended privileges.
 523		"privileged"?: bool | string
 524
 525		// Working directory for the command. Defaults to the service's working directory.
 526		"working_dir"?: string
 527
 528		// Environment variables for the command. Appended to or overriding the service environment.
 529		"environment"?: #list_or_dict
 530
 531		// Whether the hook runs once per service replica (true), or once for the
 532		// service as a whole before any replica starts (false, the default).
 533		"per_replica"?: bool | string
 534
 535		{[=~"^x-"]: _}
 536	})
 537
 538	// Secret configuration for the Compose application.
 539	#secret: close({
 540		// Custom name for this secret.
 541		"name"?: string
 542
 543		// Name of an environment variable from which to get the secret value.
 544		"environment"?: string
 545
 546		// Path to a file containing the secret value.
 547		"file"?: string
 548
 549		// Specifies that this secret already exists and was created outside of Compose.
 550		"external"?: bool | string | {
 551			// Specifies the name of the external secret.
 552			"name"?: string
 553			...
 554		}
 555
 556		// Add metadata to the secret using labels.
 557		"labels"?: #list_or_dict
 558
 559		// Specify which secret driver should be used for this secret.
 560		"driver"?: string
 561
 562		// Specify driver-specific options.
 563		"driver_opts"?: {
 564			{[=~"^.+$"]: number | string}
 565			...
 566		}
 567
 568		// Driver to use for templating the secret's value.
 569		"template_driver"?: string
 570
 571		{[=~"^x-"]: _}
 572	})
 573
 574	// Configuration for a service.
 575	#service: close({
 576		"develop"?:     #development
 577		"deploy"?:      #deployment
 578		"annotations"?: #list_or_dict
 579		"attach"?:      bool | string
 580
 581		// Configuration options for building the service's image.
 582		"build"?: matchN(1, [
 583			string,
 584			close({
 585				// Path to the build context. Can be a relative path or a URL.
 586				"context"?: string
 587
 588				// Name of the Dockerfile to use for building the image.
 589				"dockerfile"?: string
 590
 591				// Inline Dockerfile content to use instead of a Dockerfile from the build context.
 592				"dockerfile_inline"?: string
 593
 594				// List of extra privileged entitlements to grant to the build process.
 595				"entitlements"?: [...string]
 596
 597				// Build-time variables, specified as a map or a list of KEY=VAL pairs.
 598				"args"?: #list_or_dict
 599
 600				// SSH agent socket or keys to expose to the build. Format is either a string or
 601				// a list of 'default|<id>[=<socket>|<key>[,<key>]]'.
 602				"ssh"?: #list_or_dict
 603
 604				// Labels to apply to the built image.
 605				"labels"?: #list_or_dict
 606
 607				// List of sources the image builder should use for cache resolution
 608				"cache_from"?: [...string]
 609
 610				// Cache destinations for the build cache.
 611				"cache_to"?: [...string]
 612
 613				// Do not use cache when building the image.
 614				"no_cache"?: bool | string
 615
 616				// Do not use build cache for the specified stages.
 617				"no_cache_filter"?: #string_or_list
 618
 619				// Additional build contexts to use, specified as a map of name to context path or URL.
 620				"additional_contexts"?: #list_or_dict
 621
 622				// Network mode to use for the build. Options include 'default', 'none', 'host', or a network name.
 623				"network"?: string
 624
 625				// Add a provenance attestation
 626				"provenance"?: bool | string
 627
 628				// Add a SBOM attestation
 629				"sbom"?: bool | string
 630
 631				// Always attempt to pull a newer version of the image.
 632				"pull"?: bool | string
 633
 634				// Build stage to target in a multi-stage Dockerfile.
 635				"target"?: string
 636
 637				// Size of /dev/shm for the build container. A string value can use suffix like
 638				// '2g' for 2 gigabytes.
 639				"shm_size"?: int | string
 640
 641				// Add hostname mappings for the build container.
 642				"extra_hosts"?: #extra_hosts
 643
 644				// Container isolation technology to use for the build process.
 645				"isolation"?: string
 646
 647				// Give extended privileges to the build container.
 648				"privileged"?: bool | string
 649
 650				// Secrets to expose to the build. These are accessible at build-time.
 651				"secrets"?: #service_config_or_secret
 652
 653				// Additional tags to apply to the built image.
 654				"tags"?: [...string]
 655
 656				// Override the default ulimits for the build container.
 657				"ulimits"?: #ulimits
 658
 659				// Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'.
 660				"platforms"?: [...string]
 661
 662				{[=~"^x-"]: _}
 663			})
 664		])
 665
 666		// Block IO configuration for the service.
 667		"blkio_config"?: close({
 668			// Limit read rate (bytes per second) from a device.
 669			"device_read_bps"?: [...#blkio_limit]
 670
 671			// Limit read rate (IO per second) from a device.
 672			"device_read_iops"?: [...#blkio_limit]
 673
 674			// Limit write rate (bytes per second) to a device.
 675			"device_write_bps"?: [...#blkio_limit]
 676
 677			// Limit write rate (IO per second) to a device.
 678			"device_write_iops"?: [...#blkio_limit]
 679
 680			// Block IO weight (relative weight) for the service, between 10 and 1000.
 681			"weight"?: int | string
 682
 683			// Block IO weight (relative weight) for specific devices.
 684			"weight_device"?: [...#blkio_weight]
 685		})
 686
 687		// Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'.
 688		"cap_add"?: list.UniqueItems() & [...string]
 689
 690		// Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'.
 691		"cap_drop"?: list.UniqueItems() & [...string]
 692
 693		// Specify the cgroup namespace to join. Use 'host' to use the host's cgroup
 694		// namespace, or 'private' to use a private cgroup namespace.
 695		"cgroup"?: "host" | "private"
 696
 697		// Specify an optional parent cgroup for the container.
 698		"cgroup_parent"?: string
 699
 700		// Override the default command declared by the container image, for example 'CMD' in Dockerfile.
 701		"command"?: #command
 702
 703		// Grant access to Configs on a per-service basis.
 704		"configs"?: #service_config_or_secret
 705
 706		// Specify a custom container name, rather than a generated default name.
 707		"container_name"?: =~"[a-zA-Z0-9][a-zA-Z0-9_.-]+"
 708
 709		// Number of usable CPUs.
 710		"cpu_count"?: matchN(1, [string, int & >=0])
 711
 712		// Percentage of CPU resources to use.
 713		"cpu_percent"?: matchN(1, [string, int & >=0 & <=100])
 714
 715		// CPU shares (relative weight) for the container.
 716		"cpu_shares"?: number | string
 717
 718		// Limit the CPU CFS (Completely Fair Scheduler) quota.
 719		"cpu_quota"?: number | string
 720
 721		// Limit the CPU CFS (Completely Fair Scheduler) period.
 722		"cpu_period"?: number | string
 723
 724		// Limit the CPU real-time period in microseconds or a duration.
 725		"cpu_rt_period"?: number | string
 726
 727		// Limit the CPU real-time runtime in microseconds or a duration.
 728		"cpu_rt_runtime"?: number | string
 729
 730		// Number of CPUs to use. A floating-point value is supported to request partial CPUs.
 731		"cpus"?: number | string
 732
 733		// CPUs in which to allow execution (0-3, 0,1).
 734		"cpuset"?: string
 735
 736		// Configure the credential spec for managed service account.
 737		"credential_spec"?: close({
 738			// The name of the credential spec Config to use.
 739			"config"?: string
 740
 741			// Path to a credential spec file.
 742			"file"?: string
 743
 744			// Path to a credential spec in the Windows registry.
 745			"registry"?: string
 746
 747			{[=~"^x-"]: _}
 748		})
 749
 750		// Express dependency between services. Service dependencies cause services to
 751		// be started in dependency order. The dependent service will wait for the
 752		// dependency to be ready before starting.
 753		"depends_on"?: matchN(1, [
 754			#list_of_strings,
 755			close({
 756
 757				{
 758					[=~"^[a-zA-Z0-9._-]+$"]: close({
 759
 760						{[=~"^x-"]: _}
 761
 762						// Whether to restart dependent services when this service is restarted.
 763						"restart"?: bool | string
 764
 765						// Whether the dependency is required for the dependent service to start.
 766						"required"?: bool
 767
 768						// Condition to wait for. 'service_started' waits until the service has started,
 769						// 'service_healthy' waits until the service is healthy (as defined by its
 770						// healthcheck), 'service_completed_successfully' waits until the service has
 771						// completed successfully.
 772						"condition"!: "service_started" | "service_healthy" | "service_completed_successfully"
 773					})
 774				}})
 775		])
 776
 777		// Add rules to the cgroup allowed devices list.
 778		"device_cgroup_rules"?: #list_of_strings
 779
 780		// List of device mappings for the container.
 781		"devices"?: [...matchN(1, [
 782			string,
 783			close({
 784				// Path on the host to the device.
 785				"source"!: string
 786
 787				// Path in the container where the device will be mapped.
 788				"target"?: string
 789
 790				// Cgroup permissions for the device (rwm).
 791				"permissions"?: string
 792
 793				{[=~"^x-"]: _}
 794			})
 795		])]
 796
 797		// Custom DNS servers to set for the service container.
 798		"dns"?: #string_or_list
 799
 800		// Custom DNS options to be passed to the container's DNS resolver.
 801		"dns_opt"?: list.UniqueItems() & [...string]
 802
 803		// Custom DNS search domains to set on the service container.
 804		"dns_search"?: #string_or_list
 805
 806		// Custom domain name to use for the service container.
 807		"domainname"?: string
 808
 809		// Override the default entrypoint declared by the container image, for example
 810		// 'ENTRYPOINT' in Dockerfile.
 811		"entrypoint"?: #command
 812
 813		// Add environment variables from a file or multiple files. Can be a single file
 814		// path or a list of file paths.
 815		"env_file"?: #env_file
 816
 817		// Add metadata to containers using files containing Docker labels.
 818		"label_file"?: #label_file
 819
 820		// Add environment variables. You can use either an array or a list of KEY=VAL pairs.
 821		"environment"?: #list_or_dict
 822
 823		// Expose ports without publishing them to the host machine - they'll only be
 824		// accessible to linked services.
 825		"expose"?: list.UniqueItems() & [...number | string]
 826
 827		// Extend another service, in the current file or another file.
 828		"extends"?: matchN(1, [
 829			string,
 830			close({
 831				// The name of the service to extend.
 832				"service"!: string
 833
 834				// The file path where the service to extend is defined.
 835				"file"?: string
 836			})
 837		])
 838
 839		// Specify a service which will not be manage by Compose directly, and delegate
 840		// its management to an external provider.
 841		"provider"?: close({
 842			// External component used by Compose to manage setup and teardown lifecycle of the service.
 843			"type"!: string
 844
 845			// Provider-specific options.
 846			"options"?: {
 847				{[=~"^.+$"]: matchN(1, [bool | number | string, [...bool | number | string]])}
 848				...
 849			}
 850
 851			{[=~"^x-"]: _}
 852		})
 853
 854		// Link to services started outside this Compose application. Specify services
 855		// as <service_name>:<alias>.
 856		"external_links"?: list.UniqueItems() & [...string]
 857
 858		// Add hostname mappings to the container network interface configuration.
 859		"extra_hosts"?: #extra_hosts
 860
 861		// Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of
 862		// specific GPU devices.
 863		"gpus"?: #gpus
 864
 865		// Add additional groups which user inside the container should be member of.
 866		"group_add"?: list.UniqueItems() & [...number | string]
 867
 868		// Configure a health check for the container to monitor its health status.
 869		"healthcheck"?: #healthcheck
 870
 871		// Define a custom hostname for the service container.
 872		"hostname"?: string
 873
 874		// Specify the image to start the container from. Can be a repository/tag, a
 875		// digest, or a local image ID.
 876		"image"?: string
 877
 878		// Run as an init process inside the container that forwards signals and reaps processes.
 879		"init"?: bool | string
 880
 881		// IPC sharing mode for the service container. Use 'host' to share the host's
 882		// IPC namespace, 'service:[service_name]' to share with another service, or
 883		// 'shareable' to allow other services to share this service's IPC namespace.
 884		"ipc"?: string
 885
 886		// Container isolation technology to use. Supported values are platform-specific.
 887		"isolation"?: string
 888
 889		// Add metadata to containers using Docker labels. You can use either an array or a list.
 890		"labels"?: #list_or_dict
 891
 892		// Link to containers in another service. Either specify both the service name
 893		// and a link alias (SERVICE:ALIAS), or just the service name.
 894		"links"?: list.UniqueItems() & [...string]
 895
 896		// Logging configuration for the service.
 897		"logging"?: close({
 898			// Logging driver to use, such as 'json-file', 'syslog', 'journald', etc.
 899			"driver"?: string
 900
 901			// Options for the logging driver.
 902			"options"?: {
 903				{[=~"^.+$"]: null | number | string}
 904				...
 905			}
 906
 907			{[=~"^x-"]: _}
 908		})
 909
 910		// Container MAC address to set.
 911		"mac_address"?: string
 912
 913		// Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes.
 914		"mem_limit"?: number | string
 915
 916		// Memory reservation for the container.
 917		"mem_reservation"?: int | string
 918
 919		// Container memory swappiness as percentage (0 to 100).
 920		"mem_swappiness"?: int | string
 921
 922		// Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap.
 923		"memswap_limit"?: number | string
 924
 925		// Network mode. Values can be 'bridge', 'host', 'none', 'service:[service
 926		// name]', or 'container:[container name]'.
 927		"network_mode"?: string
 928
 929		// AI Models to use, referencing entries under the top-level models key.
 930		"models"?: matchN(1, [
 931			#list_of_strings,
 932			{
 933				{
 934					[=~"^[a-zA-Z0-9._-]+$"]: matchN(1, [
 935						close({
 936							// Environment variable set to AI model endpoint.
 937							"endpoint_var"?: string
 938
 939							// Environment variable set to AI model name.
 940							"model_var"?: string
 941
 942							{[=~"^x-"]: _}
 943						}),
 944						null
 945					])
 946				}
 947				...
 948			}
 949		])
 950
 951		// Networks to join, referencing entries under the top-level networks key. Can
 952		// be a list of network names or a mapping of network name to network
 953		// configuration.
 954		"networks"?: matchN(1, [
 955			#list_of_strings,
 956			close({
 957
 958				{
 959					[=~"^[a-zA-Z0-9._-]+$"]: matchN(1, [
 960						close({
 961							// Alternative hostnames for this service on the network.
 962							"aliases"?: #list_of_strings
 963
 964							// Interface network name used to connect to network
 965							"interface_name"?: string
 966
 967							// Specify a static IPv4 address for this service on this network.
 968							"ipv4_address"?: string
 969
 970							// Specify a static IPv6 address for this service on this network.
 971							"ipv6_address"?: string
 972
 973							// List of link-local IPs.
 974							"link_local_ips"?: #list_of_strings
 975
 976							// Specify a MAC address for this service on this network.
 977							"mac_address"?: string
 978
 979							// Driver options for this network.
 980							"driver_opts"?: {
 981								{[=~"^.+$"]: number | string}
 982								...
 983							}
 984
 985							// Specify the priority for the network connection.
 986							"priority"?: number
 987
 988							// Specify the gateway priority for the network connection.
 989							"gw_priority"?: number
 990
 991							{[=~"^x-"]: _}
 992						}),
 993						null
 994					])
 995				}})
 996		])
 997
 998		// Disable OOM Killer for the container.
 999		"oom_kill_disable"?: bool | string
1000
1001		// Tune host's OOM preferences for the container (accepts -1000 to 1000).
1002		"oom_score_adj"?: matchN(1, [string, int & >=-1000 & <=1000])
1003
1004		// PID mode for container.
1005		"pid"?: null | string
1006
1007		// Tune a container's PIDs limit. Set to -1 for unlimited PIDs.
1008		"pids_limit"?: number | string
1009
1010		// Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'.
1011		"platform"?: string
1012
1013		// Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).
1014		"ports"?: list.UniqueItems() & [...matchN(1, [
1015			number,
1016			string,
1017			close({
1018				// A human-readable name for this port mapping.
1019				"name"?: string
1020
1021				// The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing.
1022				"mode"?: string
1023
1024				// The host IP to bind to.
1025				"host_ip"?: string
1026
1027				// The port inside the container.
1028				"target"?: int | string
1029
1030				// The publicly exposed port.
1031				"published"?: int | string
1032
1033				// The port protocol (tcp or udp).
1034				"protocol"?: string
1035
1036				// Application protocol to use with the port (e.g., http, https, mysql).
1037				"app_protocol"?: string
1038
1039				{[=~"^x-"]: _}
1040			})
1041		])]
1042
1043		// Init containers to run to completion before the service container is started.
1044		// Each step runs in its own ephemeral container, in declared order; a non-zero
1045		// exit fails the bring-up of the service and its dependents.
1046		"pre_start"?: [...#pre_start_hook]
1047
1048		// Commands to run after the container starts. If any command fails, the container stops.
1049		"post_start"?: [...#service_hook]
1050
1051		// Commands to run before the container stops. If any command fails, the container stop is aborted.
1052		"pre_stop"?: [...#service_hook]
1053
1054		// Give extended privileges to the service container.
1055		"privileged"?: bool | string
1056
1057		// List of profiles for this service. When profiles are specified, services are
1058		// only started when the profile is activated.
1059		"profiles"?: #list_of_strings
1060
1061		// Policy for pulling images. Options include: 'always', 'never',
1062		// 'if_not_present', 'missing', 'build', or time-based refresh policies.
1063		"pull_policy"?: =~"always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+"
1064
1065		// Time after which to refresh the image. Used with pull_policy=refresh.
1066		"pull_refresh_after"?: string
1067
1068		// Mount the container's filesystem as read only.
1069		"read_only"?: bool | string
1070
1071		// Restart policy for the service container. Options include: 'no', 'always',
1072		// 'on-failure', and 'unless-stopped'.
1073		"restart"?: string
1074
1075		// Runtime to use for this container, e.g., 'runc'.
1076		"runtime"?: string
1077
1078		// Number of containers to deploy for this service.
1079		"scale"?: int | string
1080
1081		// Override the default labeling scheme for each container.
1082		"security_opt"?: list.UniqueItems() & [...string]
1083
1084		// Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes.
1085		"shm_size"?: number | string
1086
1087		// Grant access to Secrets on a per-service basis.
1088		"secrets"?: #service_config_or_secret
1089
1090		// Kernel parameters to set in the container. You can use either an array or a list.
1091		"sysctls"?: #list_or_dict
1092
1093		// Keep STDIN open even if not attached.
1094		"stdin_open"?: bool | string
1095
1096		// Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s').
1097		"stop_grace_period"?: string
1098
1099		// Signal to stop the container (e.g., 'SIGTERM', 'SIGINT').
1100		"stop_signal"?: string
1101
1102		// Storage driver options for the container.
1103		"storage_opt"?: {...}
1104
1105		// Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list.
1106		"tmpfs"?: #string_or_list
1107
1108		// Allocate a pseudo-TTY to service container.
1109		"tty"?: bool | string
1110
1111		// Override the default ulimits for a container.
1112		"ulimits"?: #ulimits
1113
1114		// Bind mount Docker API socket and required auth.
1115		"use_api_socket"?: bool
1116
1117		// Username or UID to run the container process as.
1118		"user"?: string
1119
1120		// UTS namespace to use. 'host' shares the host's UTS namespace.
1121		"uts"?: string
1122
1123		// User namespace to use. 'host' shares the host's user namespace.
1124		"userns_mode"?: string
1125
1126		// Mount host paths or named volumes accessible to the container. Short syntax
1127		// (VOLUME:CONTAINER_PATH[:MODE])
1128		"volumes"?: list.UniqueItems() & [...matchN(1, [
1129			string,
1130			close({
1131				// The mount type: bind for mounting host directories, volume for named volumes,
1132				// tmpfs for temporary filesystems, cluster for cluster volumes, npipe for
1133				// named pipes, or image for mounting from an image.
1134				"type"!: "bind" | "volume" | "tmpfs" | "cluster" | "npipe" | "image"
1135
1136				// The source of the mount, a path on the host for a bind mount, a docker image
1137				// reference for an image mount, or the name of a volume defined in the
1138				// top-level volumes key. Not applicable for a tmpfs mount.
1139				"source"?: string
1140
1141				// The path in the container where the volume is mounted.
1142				"target"?: string
1143
1144				// Flag to set the volume as read-only.
1145				"read_only"?: bool | string
1146
1147				// The consistency requirements for the mount. Available values are platform specific.
1148				"consistency"?: string
1149
1150				// Configuration specific to bind mounts.
1151				"bind"?: close({
1152					// The propagation mode for the bind mount: 'shared', 'slave', 'private',
1153					// 'rshared', 'rslave', or 'rprivate'.
1154					"propagation"?: string
1155
1156					// Create the host path if it doesn't exist.
1157					"create_host_path"?: bool | string
1158
1159					// Recursively mount the source directory.
1160					"recursive"?: "enabled" | "disabled" | "writable" | "readonly"
1161
1162					// SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content.
1163					"selinux"?: "z" | "Z"
1164
1165					{[=~"^x-"]: _}
1166				})
1167
1168				// Configuration specific to volume mounts.
1169				"volume"?: close({
1170					// Labels to apply to the volume.
1171					"labels"?: #list_or_dict
1172
1173					// Flag to disable copying of data from a container when a volume is created.
1174					"nocopy"?: bool | string
1175
1176					// Path within the volume to mount instead of the volume root.
1177					"subpath"?: string
1178
1179					{[=~"^x-"]: _}
1180				})
1181
1182				// Configuration specific to tmpfs mounts.
1183				"tmpfs"?: close({
1184					// Size of the tmpfs mount in bytes.
1185					"size"?: matchN(1, [int & >=0, string])
1186
1187					// File mode of the tmpfs in octal.
1188					"mode"?: number | string
1189
1190					{[=~"^x-"]: _}
1191				})
1192
1193				// Configuration specific to image mounts.
1194				"image"?: close({
1195					// Path within the image to mount instead of the image root.
1196					"subpath"?: string
1197
1198					{[=~"^x-"]: _}
1199				})
1200
1201				{[=~"^x-"]: _}
1202			})
1203		])]
1204
1205		// Mount volumes from another service or container. Optionally specify read-only
1206		// access (ro) or read-write (rw).
1207		"volumes_from"?: list.UniqueItems() & [...string]
1208
1209		// The working directory in which the entrypoint or command will be run
1210		"working_dir"?: string
1211
1212		{[=~"^x-"]: _}
1213	})
1214
1215	// Configuration for service configs or secrets, defining how they are mounted in the container.
1216	#service_config_or_secret: [...matchN(1, [
1217		string,
1218		close({
1219			// Name of the config or secret as defined in the top-level configs or secrets section.
1220			"source"?: string
1221
1222			// Path in the container where the config or secret will be mounted. Defaults to
1223			// /<source> for configs and /run/secrets/<source> for secrets.
1224			"target"?: string
1225
1226			// UID of the file in the container. Default is 0 (root).
1227			"uid"?: string
1228
1229			// GID of the file in the container. Default is 0 (root).
1230			"gid"?: string
1231
1232			// File permission mode inside the container, in octal. Default is 0444 for
1233			// configs and 0400 for secrets.
1234			"mode"?: number | string
1235
1236			{[=~"^x-"]: _}
1237		})
1238	])]
1239
1240	// Configuration for service lifecycle hooks, which are commands executed at
1241	// specific points in a container's lifecycle.
1242	#service_hook: close({
1243		// Command to execute as part of the hook.
1244		"command"!: #command
1245
1246		// User to run the command as.
1247		"user"?: string
1248
1249		// Whether to run the command with extended privileges.
1250		"privileged"?: bool | string
1251
1252		// Working directory for the command.
1253		"working_dir"?: string
1254
1255		// Environment variables for the command.
1256		"environment"?: #list_or_dict
1257
1258		{[=~"^x-"]: _}
1259	})
1260
1261	// Either a single string or a list of strings.
1262	#string_or_list: matchN(1, [string, #list_of_strings])
1263
1264	// Container ulimit options, controlling resource limits for processes inside the container.
1265	#ulimits: {
1266		{
1267			[=~"^[a-z]+$"]: matchN(1, [
1268				int | string,
1269				close({
1270					// Hard limit for the ulimit type. This is the maximum allowed value.
1271					"hard"!: int | string
1272
1273					// Soft limit for the ulimit type. This is the value that's actually enforced.
1274					"soft"!: int | string
1275
1276					{[=~"^x-"]: _}
1277				})
1278			])
1279		}
1280		...
1281	}
1282
1283	// Volume configuration for the Compose application.
1284	#volume: null | close({
1285		// Custom name for this volume.
1286		"name"?: string
1287
1288		// Specify which volume driver should be used for this volume.
1289		"driver"?: string
1290
1291		// Specify driver-specific options.
1292		"driver_opts"?: {
1293			{[=~"^.+$"]: number | string}
1294			...
1295		}
1296
1297		// Specifies that this volume already exists and was created outside of Compose.
1298		"external"?: bool |
1299		string |
1300		close({
1301			// Specifies the name of the external volume. Deprecated: use the 'name' property instead.
1302			"name"?: string @deprecated()
1303
1304			{[=~"^x-"]: _}
1305		})
1306
1307		// Add metadata to the volume using labels.
1308		"labels"?: #list_or_dict
1309
1310		{[=~"^x-"]: _}
1311	})
1312}