Declaratively create, update or delete Services or Volumes belonging to a Stack
PUT/stacks/ {stackId}/
v2
PUT
container-declare-stack
This command can be used to declare the desired state of a container stack.
Usage
Obtaining the default stack
Every mStudio project comes with a default stack named default
. You can obtain the default stack by using the unknown operation container-list-stack
operation.
Creating new stacks
Creating new stacks is not supported at this time. You can only manage the default
stack.
Managing volumes
You have two options for managing storage for your container stacks:
- Explicitly declare volumes, using the
$.volumes
property of this request. Volumes are referenced by name, and can be mounted into the container by referencing them in the$.services[*].volumes
property in the format<volume-name>:<mount-path>
. - Use the project volume; this volume is shared among all managed apps and containers of a project. In order to mount the project volume, specify a file path instead of a volume name when mounting the volume (example
/home/p-XXXXX/html:/var/html
).
Request
Responses
Usage examples
- cURL
- JavaScript SDK
- PHP SDK
$ curl \
--fail \
--location \
-X PUT \
-d '{"services":{"mysql":{"command":["mysqld"],"description":"MySQL DB","entrypoint":["docker-entrypoint.sh"],"envs":{"MYSQL_DATABASE":"my_db","MYSQL_PASSWORD":"my_password","MYSQL_ROOT_PASSWORD":"my_root_password","MYSQL_USER":"my_user"},"image":"mysql","ports":["3306:3306/tcp"],"volumes":["data:/var/lib/mysql","/home/p-XXXXX/html:/var/www"]}},"volumes":{"data":{"name":"mysql-volume"}}}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/stacks/f0f86186-0a5a-45b2-aa33-502777496347
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";
const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.container.declareStack({
"stackId": "f0f86186-0a5a-45b2-aa33-502777496347",
"data": {
"services": {
"mysql": {
"command": [
"mysqld"
],
"description": "MySQL DB",
"entrypoint": [
"docker-entrypoint.sh"
],
"envs": {
"MYSQL_DATABASE": "my_db",
"MYSQL_PASSWORD": "my_password",
"MYSQL_ROOT_PASSWORD": "my_root_password",
"MYSQL_USER": "my_user"
},
"image": "mysql",
"ports": [
"3306:3306/tcp"
],
"volumes": [
"data:/var/lib/mysql",
"/home/p-XXXXX/html:/var/www"
]
}
},
"volumes": {
"data": {
"name": "mysql-volume"
}
}
}
});
assertStatus(response, 200);
use \Mittwald\ApiClient\Generated\V2\Clients\Container\DeclareStack\DeclareStackRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\Container\DeclareStack\DeclareStackRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// DeclareStackRequestBody to learn how to construct a valid instance
$body = new DeclareStackRequestBody(/* TODO: ... */);
$request = (new DeclareStackRequest(
stackId: "f0f86186-0a5a-45b2-aa33-502777496347",
body: $body
));
$response = $client->container()->declareStack($request);
var_dump($response->getBody();