Skip to content

Commit 433649b

Browse files
committed
Introduce jobs top-level element
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 2e680da commit 433649b

1 file changed

Lines changed: 56 additions & 14 deletions

File tree

schema/compose-spec.json

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@
8888
},
8989
"additionalProperties": false,
9090
"description": "Configurations that are shared among multiple services."
91+
},
92+
93+
"jobs": {
94+
"type": "object",
95+
"patternProperties": {
96+
"^[a-zA-Z0-9._-]+$": {
97+
"$ref": "#/$defs/job"
98+
}
99+
},
100+
"additionalProperties": false,
101+
"description": "Jobs are containers that run to completion, triggered manually or on a schedule."
91102
}
92103
},
93104

@@ -96,12 +107,10 @@
96107

97108
"$defs": {
98109

99-
"service": {
110+
"container_spec": {
100111
"type": "object",
101-
"description": "Configuration for a service.",
112+
"description": "Reusable container specification shared by services, jobs, and other container types.",
102113
"properties": {
103-
"develop": {"$ref": "#/$defs/development"},
104-
"deploy": {"$ref": "#/$defs/deployment"},
105114
"annotations": {"$ref": "#/$defs/list_or_dict"},
106115
"attach": {"type": ["boolean", "string"]},
107116
"build": {
@@ -702,10 +711,6 @@
702711
"type": ["boolean", "string"],
703712
"description": "Give extended privileges to the service container."
704713
},
705-
"profiles": {
706-
"$ref": "#/$defs/list_of_strings",
707-
"description": "List of profiles for this service. When profiles are specified, services are only started when the profile is activated."
708-
},
709714
"pull_policy": {
710715
"type": "string",
711716
"pattern": "always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+",
@@ -727,10 +732,6 @@
727732
"type": "string",
728733
"description": "Runtime to use for this container, e.g., 'runc'."
729734
},
730-
"scale": {
731-
"type": ["integer", "string"],
732-
"description": "Number of containers to deploy for this service."
733-
},
734735
"security_opt": {
735736
"type": "array",
736737
"items": {"type": "string"},
@@ -920,8 +921,49 @@
920921
"description": "The working directory in which the entrypoint or command will be run"
921922
}
922923
},
923-
"patternProperties": {"^x-": {}},
924-
"additionalProperties": false
924+
"patternProperties": {"^x-": {}}
925+
},
926+
927+
"service": {
928+
"description": "Configuration for a service.",
929+
"allOf": [{"$ref": "#/$defs/container_spec"}],
930+
"properties": {
931+
"deploy": {"$ref": "#/$defs/deployment"},
932+
"develop": {"$ref": "#/$defs/development"},
933+
"profiles": {
934+
"$ref": "#/$defs/list_of_strings",
935+
"description": "List of profiles for this service. When profiles are specified, services are only started when the profile is activated."
936+
},
937+
"scale": {
938+
"type": ["integer", "string"],
939+
"description": "Number of containers to deploy for this service."
940+
}
941+
},
942+
"unevaluatedProperties": false
943+
},
944+
945+
"job": {
946+
"description": "Configuration for a job. Jobs are containers that run to completion.",
947+
"allOf": [{"$ref": "#/$defs/container_spec"}],
948+
"properties": {
949+
"triggers": {
950+
"type": "object",
951+
"description": "Trigger conditions for the job.",
952+
"properties": {
953+
"manual": {
954+
"type": "boolean",
955+
"description": "Whether the job can be triggered manually via docker compose run."
956+
},
957+
"schedule": {
958+
"type": "string",
959+
"description": "Crontab expression to schedule the job (e.g. '0 * * * *' for every hour)."
960+
}
961+
},
962+
"additionalProperties": false,
963+
"patternProperties": {"^x-": {}}
964+
}
965+
},
966+
"unevaluatedProperties": false
925967
},
926968

927969
"healthcheck": {

0 commit comments

Comments
 (0)