This repository was archived by the owner on Oct 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathImageBuild.php
More file actions
168 lines (145 loc) · 9.27 KB
/
ImageBuild.php
File metadata and controls
168 lines (145 loc) · 9.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
declare(strict_types=1);
/*
* This file has been auto generated by Jane,
*
* Do no edit it directly.
*/
namespace Docker\API\Endpoint;
class ImageBuild extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\AmpArtaxEndpoint, \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint
{
/**
* Build an image from a tar archive with a `Dockerfile` in it.
The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](https://docs.docker.com/engine/reference/builder/).
The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.
The build is canceled if the client drops the connection by quitting or being killed.
*
* @param string|resource|\Psr\Http\Message\StreamInterface $inputStream a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz
* @param array $queryParameters {
*
* @var string $dockerfile Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`.
* @var string $t A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters.
* @var string $extrahosts Extra hosts to add to /etc/hosts
* @var string $remote A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball.
* @var bool $q suppress verbose build output
* @var bool $nocache do not use the cache when building the image
* @var string $cachefrom JSON array of images used for build cache resolution
* @var string $pull attempt to pull the image even if an older image exists locally
* @var bool $rm remove intermediate containers after a successful build
* @var bool $forcerm always remove intermediate containers, even upon failure
* @var int $memory set memory limit for build
* @var int $memswap Total memory (memory + swap). Set as `-1` to disable swap.
* @var int $cpushares CPU shares (relative weight)
* @var string $cpusetcpus CPUs in which to allow execution (e.g., `0-3`, `0,1`).
* @var int $cpuperiod the length of a CPU period in microseconds
* @var int $cpuquota microseconds of CPU time that the container can get in a CPU period
* @var string $buildargs JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values.
* @var int $shmsize Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB.
* @var bool $squash Squash the resulting images layers into a single layer. *(Experimental release only.)*
* @var string $labels arbitrary key/value labels to set on the image, as a JSON map of string pairs
* @var string $networkmode Sets the networking mode for the run commands during build. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken as a custom network's name to which this container should connect to.
* @var string $platform Platform in the format os[/arch[/variant]]
* }
*
* @param array $headerParameters {
*
* @var string $Content-type
* @var string $X-Registry-Config This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to
The key is a registry URL, and the value is an auth configuration object, [as described in the authentication section](#section/Authentication). For example:
```
{
"docker.example.com": {
"username": "janedoe",
"password": "hunter2"
},
"https://index.docker.io/v1/": {
"username": "mobydock",
"password": "conta1n3rize14"
}
}
```
Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API.
* }
*/
public function __construct($inputStream, array $queryParameters = [], array $headerParameters = [])
{
$this->body = $inputStream;
$this->queryParameters = $queryParameters;
$this->headerParameters = $headerParameters;
}
use \Jane\OpenApiRuntime\Client\AmpArtaxEndpointTrait, \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait;
public function getMethod(): string
{
return 'POST';
}
public function getUri(): string
{
return '/build';
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null): array
{
return [[], $this->body];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
$optionsResolver->setDefined(['dockerfile', 't', 'extrahosts', 'remote', 'q', 'nocache', 'cachefrom', 'pull', 'rm', 'forcerm', 'memory', 'memswap', 'cpushares', 'cpusetcpus', 'cpuperiod', 'cpuquota', 'buildargs', 'shmsize', 'squash', 'labels', 'networkmode', 'platform']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults(['dockerfile' => 'Dockerfile', 'q' => false, 'nocache' => false, 'rm' => true, 'forcerm' => false, 'platform' => '']);
$optionsResolver->setAllowedTypes('dockerfile', ['string']);
$optionsResolver->setAllowedTypes('t', ['string']);
$optionsResolver->setAllowedTypes('extrahosts', ['string']);
$optionsResolver->setAllowedTypes('remote', ['string']);
$optionsResolver->setAllowedTypes('q', ['bool']);
$optionsResolver->setAllowedTypes('nocache', ['bool']);
$optionsResolver->setAllowedTypes('cachefrom', ['string']);
$optionsResolver->setAllowedTypes('pull', ['string']);
$optionsResolver->setAllowedTypes('rm', ['bool']);
$optionsResolver->setAllowedTypes('forcerm', ['bool']);
$optionsResolver->setAllowedTypes('memory', ['int']);
$optionsResolver->setAllowedTypes('memswap', ['int']);
$optionsResolver->setAllowedTypes('cpushares', ['int']);
$optionsResolver->setAllowedTypes('cpusetcpus', ['string']);
$optionsResolver->setAllowedTypes('cpuperiod', ['int']);
$optionsResolver->setAllowedTypes('cpuquota', ['int']);
$optionsResolver->setAllowedTypes('buildargs', ['string']);
$optionsResolver->setAllowedTypes('shmsize', ['int']);
$optionsResolver->setAllowedTypes('squash', ['bool']);
$optionsResolver->setAllowedTypes('labels', ['string']);
$optionsResolver->setAllowedTypes('networkmode', ['string']);
$optionsResolver->setAllowedTypes('platform', ['string']);
return $optionsResolver;
}
protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getHeadersOptionsResolver();
$optionsResolver->setDefined(['Content-type', 'X-Registry-Config']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults(['Content-type' => 'application/x-tar']);
$optionsResolver->setAllowedTypes('Content-type', ['string']);
$optionsResolver->setAllowedTypes('X-Registry-Config', ['string']);
return $optionsResolver;
}
/**
* {@inheritdoc}
*
* @throws \Docker\API\Exception\ImageBuildBadRequestException
* @throws \Docker\API\Exception\ImageBuildInternalServerErrorException
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer)
{
if (200 === $status) {
return null;
}
if (400 === $status) {
throw new \Docker\API\Exception\ImageBuildBadRequestException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'));
}
if (500 === $status) {
throw new \Docker\API\Exception\ImageBuildInternalServerErrorException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'));
}
}
}