1 | <?php |
||
7 | class ContextBuilder |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $directory; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $from = 'base'; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $commands = []; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $files = []; |
||
28 | |||
29 | /** |
||
30 | * @var \Symfony\Component\Filesystem\Filesystem |
||
31 | */ |
||
32 | private $fs; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $format; |
||
38 | |||
39 | /** |
||
40 | * @param \Symfony\Component\Filesystem\Filesystem |
||
41 | */ |
||
42 | 12 | public function __construct(Filesystem $fs = null) |
|
47 | |||
48 | /** |
||
49 | * Sets the format of the Context output |
||
50 | * |
||
51 | * @param string $format |
||
52 | * |
||
53 | * @return \Docker\Context\ContextBuilder |
||
54 | */ |
||
55 | public function setFormat($format) |
||
61 | |||
62 | /** |
||
63 | * Set the FROM instruction of Dockerfile |
||
64 | * |
||
65 | * @param string $from From which image we start |
||
66 | * |
||
67 | * @return \Docker\Context\ContextBuilder |
||
68 | */ |
||
69 | 5 | public function from($from) |
|
75 | |||
76 | /** |
||
77 | * Add a ADD instruction to Dockerfile |
||
78 | * |
||
79 | * @param string $path Path wanted on the image |
||
80 | * @param string $content Content of file |
||
81 | * |
||
82 | * @return \Docker\Context\ContextBuilder |
||
83 | */ |
||
84 | 6 | public function add($path, $content) |
|
90 | |||
91 | /** |
||
92 | * Add a RUN instruction to Dockerfile |
||
93 | * |
||
94 | * @param string $command Command to run |
||
95 | * |
||
96 | * @return \Docker\Context\ContextBuilder |
||
97 | */ |
||
98 | 1 | public function run($command) |
|
104 | |||
105 | /** |
||
106 | * Create context given the state of builder |
||
107 | * |
||
108 | * @return \Docker\Context\Context |
||
109 | */ |
||
110 | 12 | public function getContext() |
|
122 | |||
123 | /** |
||
124 | * @void |
||
125 | */ |
||
126 | 12 | public function __destruct() |
|
130 | |||
131 | /** |
||
132 | * Write docker file and associated files in a directory |
||
133 | * |
||
134 | * @param string $directory Target directory |
||
135 | * |
||
136 | * @void |
||
137 | */ |
||
138 | 12 | private function write($directory) |
|
156 | |||
157 | /** |
||
158 | * Generated a file in a directory |
||
159 | * |
||
160 | * @param string $directory Targeted directory |
||
161 | * @param string $content Content of file |
||
162 | * |
||
163 | * @return string Name of file generated |
||
164 | */ |
||
165 | 6 | private function getFile($directory, $content) |
|
177 | |||
178 | /** |
||
179 | * Clean directory generated |
||
180 | */ |
||
181 | 12 | private function cleanDirectory() |
|
185 | } |
||
186 |