0

Edit container

by
Published Oct 17, 2025

- To edit the container you must have the admin permission. - For port edition, if you provide a port id, we will update the corresponding port. If you don't we will create a new one. If you remove a port from the payload, we will delete it. - For storage edition, if you provide a storage id, we will update the corresponding storage. If you don't we will create a new one. If you remove a storage from the payload, we will delete it.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit container
4
 * - To edit the container you must have the admin permission.
5
- For port edition, if you provide a port id, we will update the corresponding port. If you don't we will create a new one. If you remove a port from the payload, we will delete it.
6
- For storage edition, if you provide a storage id, we will update the corresponding storage. If you don't we will create a new one. If you remove a storage from the payload, we will delete it.
7

8
 */
9
export async function main(auth: RT.Qovery, containerId: string, body: Body) {
10
	const url = new URL(`https://api.qovery.com/container/${containerId}`)
11

12
	const response = await fetch(url, {
13
		method: 'PUT',
14
		headers: {
15
			'Content-Type': 'application/json',
16
			Authorization: 'Token ' + auth.apiKey
17
		},
18
		body: JSON.stringify(body)
19
	})
20
	if (!response.ok) {
21
		const text = await response.text()
22
		throw new Error(`${response.status} ${text}`)
23
	}
24
	return await response.json()
25
}
26

27
/* eslint-disable */
28
/**
29
 * This file was automatically generated by json-schema-to-typescript.
30
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
31
 * and run json-schema-to-typescript to regenerate this file.
32
 */
33

34
export type Body = {
35
	storage?: {
36
		id?: string
37
		type: 'FAST_SSD'
38
		/**
39
		 * unit is GB
40
		 * Minimum size is 4 GB
41
		 *
42
		 */
43
		size: number
44
		mount_point: string
45
		[k: string]: unknown
46
	}[]
47
	[k: string]: unknown
48
} & {
49
	ports?: {
50
		id?: string
51
		name?: string
52
		/**
53
		 * The listening port of your service.
54
		 */
55
		internal_port: number
56
		/**
57
		 * The exposed port for your service. This is optional. If not set a default port will be used.
58
		 */
59
		external_port?: number
60
		/**
61
		 * Expose the port to the world
62
		 */
63
		publicly_accessible: boolean
64
		/**
65
		 * is the default port to use for domain
66
		 */
67
		is_default?: boolean
68
		protocol?: 'HTTP' | 'GRPC' | 'TCP' | 'UDP'
69
		/**
70
		 * Indicate the path or regex that must match for traffic to be accepted on your service
71
		 * i.e: /api/ will only accept http calls that start with /api/
72
		 * Only valid for publicly_accessible HTTP or GRPC ports.
73
		 */
74
		public_path?: string
75
		/**
76
		 * Indicate the new path that will be used to reach your service after replacement
77
		 * i.e: public_path -> /(.*)  public_path_rewrite -> /api/$1 will append /api/ on all externaly requested url when reaching the service
78
		 * external/use url -> example.com/foobar  -> url seen by the service -> example.com/api/foobar
79
		 * Only valid for publicly_accessible HTTP or GRPC ports.
80
		 */
81
		public_path_rewrite?: string
82
		[k: string]: unknown
83
	}[]
84
	[k: string]: unknown
85
} & {
86
	/**
87
	 * name is case insensitive
88
	 */
89
	name: string
90
	/**
91
	 * give a description to this container
92
	 */
93
	description?: string
94
	/**
95
	 * id of the linked registry
96
	 */
97
	registry_id: string
98
	/**
99
	 * The image name pattern differs according to chosen container registry provider:
100
	 * * `ECR`: `repository`
101
	 * * `SCALEWAY_CR`: `namespace/image`
102
	 * * `DOCKER_HUB`: `image` or `repository/image`
103
	 * * `PUBLIC_ECR`: `registry_alias/repository`
104
	 *
105
	 */
106
	image_name: string
107
	/**
108
	 * tag of the image container
109
	 */
110
	tag: string
111
	arguments?: string[]
112
	/**
113
	 * optional entrypoint when launching container
114
	 */
115
	entrypoint?: string
116
	/**
117
	 * unit is millicores (m). 1000m = 1 cpu
118
	 */
119
	cpu?: number
120
	/**
121
	 * unit is MB. 1024 MB = 1GB
122
	 */
123
	memory?: number
124
	gpu?: number
125
	/**
126
	 * Minimum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
127
	 * Note: 0 means that there is no container running.
128
	 *
129
	 */
130
	min_running_instances?: number
131
	/**
132
	 * Maximum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
133
	 * Note: -1 means that there is no limit.
134
	 *
135
	 */
136
	max_running_instances?: number
137
	healthchecks: {
138
		readiness_probe?: {
139
			type?: {
140
				tcp?: {
141
					port?: number
142
					host?: string
143
					[k: string]: unknown
144
				}
145
				http?: {
146
					path?: string
147
					scheme?: string
148
					port?: number
149
					[k: string]: unknown
150
				}
151
				exec?: {
152
					command?: string[]
153
					[k: string]: unknown
154
				}
155
				grpc?: {
156
					service?: string
157
					port?: number
158
					[k: string]: unknown
159
				}
160
				[k: string]: unknown
161
			}
162
			initial_delay_seconds?: number
163
			period_seconds?: number
164
			timeout_seconds?: number
165
			success_threshold?: number
166
			failure_threshold?: number
167
			[k: string]: unknown
168
		}
169
		liveness_probe?: {
170
			type?: {
171
				tcp?: {
172
					port?: number
173
					host?: string
174
					[k: string]: unknown
175
				}
176
				http?: {
177
					path?: string
178
					scheme?: string
179
					port?: number
180
					[k: string]: unknown
181
				}
182
				exec?: {
183
					command?: string[]
184
					[k: string]: unknown
185
				}
186
				grpc?: {
187
					service?: string
188
					port?: number
189
					[k: string]: unknown
190
				}
191
				[k: string]: unknown
192
			}
193
			initial_delay_seconds?: number
194
			period_seconds?: number
195
			timeout_seconds?: number
196
			success_threshold?: number
197
			failure_threshold?: number
198
			[k: string]: unknown
199
		}
200
		[k: string]: unknown
201
	}
202
	/**
203
	 * Indicates if the 'environment preview option' is enabled for this container.
204
	 * If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
205
	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
206
	 *
207
	 */
208
	auto_preview?: boolean
209
	/**
210
	 * Specify if the container will be automatically updated after receiving a new image tag.
211
	 * The new image tag shall be communicated via the "Auto Deploy container" endpoint https://api-doc.qovery.com/#tag/Containers/operation/autoDeployContainerEnvironments
212
	 *
213
	 */
214
	auto_deploy?: boolean
215
	annotations_groups?: {
216
		id: string
217
		[k: string]: unknown
218
	}[]
219
	labels_groups?: {
220
		id: string
221
		[k: string]: unknown
222
	}[]
223
	/**
224
	 * Icon URI representing the container.
225
	 */
226
	icon_uri?: string
227
	[k: string]: unknown
228
}
229