1 | <?php |
||
20 | class Module extends \yii\base\Module |
||
21 | { |
||
22 | /** |
||
23 | * The variables will be written to /runtime/env.json as JSON, where your application can read them. |
||
24 | * @var string[] List of required environment variables. If one is missing the container will exit. |
||
25 | * |
||
26 | */ |
||
27 | public $environmentVariables = []; |
||
28 | |||
29 | /** |
||
30 | * @var array Pool directives |
||
31 | * @see http://php.net/manual/en/install.fpm.configuration.php |
||
32 | * |
||
33 | */ |
||
34 | public $poolConfig = [ |
||
35 | 'user' => 'nobody', |
||
36 | 'group' => 'nobody', |
||
37 | 'listen' => 9000, |
||
38 | 'pm' => 'dynamic', |
||
39 | 'pm.max_children' => 40, |
||
40 | 'pm.start_servers' => 3, |
||
41 | 'pm.min_spare_servers' => 1, |
||
42 | 'pm.max_spare_servers' => 3, |
||
43 | 'access.log' => '/proc/self/fd/2', |
||
44 | 'clear_env' => 'yes', |
||
45 | 'catch_workers_output' => 'yes' |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @var array PHP configuration, supplied via php_admin_value in fpm config. |
||
50 | */ |
||
51 | public $phpConfig = [ |
||
52 | 'upload_max_filesize' => '20M', |
||
53 | 'post_max_size' => '25M' |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * @var array Global directives |
||
58 | * @see http://php.net/manual/en/install.fpm.configuration.php |
||
59 | * |
||
60 | */ |
||
61 | public $fpmConfig = [ |
||
62 | 'error_log' => '/proc/self/fd/2', |
||
63 | 'daemonize' => 'no', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * List of php extensions to install |
||
68 | */ |
||
69 | public $extensions = [ |
||
70 | 'ctype', |
||
71 | 'gd', |
||
72 | 'iconv', |
||
73 | 'intl', |
||
74 | 'json', |
||
75 | 'mbstring', |
||
76 | 'session', |
||
77 | 'pdo_mysql', |
||
78 | 'session', |
||
79 | 'curl' |
||
80 | ]; |
||
81 | |||
82 | /** |
||
83 | * @var string The name of the created image. |
||
84 | */ |
||
85 | public $image; |
||
86 | |||
87 | /** |
||
88 | * @var string The tag of the created image. |
||
89 | */ |
||
90 | public $tag = 'latest'; |
||
91 | |||
92 | /** |
||
93 | * @var bool wheter to push successful builds. |
||
94 | */ |
||
95 | public $push = false; |
||
96 | |||
97 | /** |
||
98 | * @var string Location of composer.json / composer.lock |
||
99 | */ |
||
100 | public $composerFilePath = '@app/../'; |
||
101 | |||
102 | /** |
||
103 | * @var string[] List of console commands that are executed upon container launch. |
||
104 | */ |
||
105 | public $initializationCommands = []; |
||
106 | /** |
||
107 | * @return string A PHP-FPM config file. |
||
108 | */ |
||
109 | 3 | protected function createFpmConfig() |
|
131 | |||
132 | /** |
||
133 | * @return string A shell script that checks for existence of (non-empty) variables and runs php-fpm. |
||
134 | */ |
||
135 | 3 | private function createEntrypoint(string $entryScript): string |
|
182 | |||
183 | /** |
||
184 | * @param Context $context The context to use |
||
185 | * @param string $version This is stored in the VERSION environment variable. |
||
186 | * @param string $sourcePath This is the path where app source is stored, it must be a top level dir, the project root is derived from it |
||
187 | * @throws InvalidConfigException |
||
188 | */ |
||
189 | 5 | public function createBuildContext( |
|
242 | |||
243 | /** |
||
244 | * @throws \InvalidArgumentException in case the app is not configured as expected |
||
245 | * @param string $sourcePath the path to the soruce files |
||
246 | * @return string the relative path of the (console) entry script with respect to the project (not app) root. |
||
247 | */ |
||
248 | 4 | private function getConsoleEntryScript(string $sourcePath): string |
|
257 | |||
258 | |||
259 | 3 | public function __set($name, $value): void |
|
269 | |||
270 | 3 | private function add($name, array $value): void |
|
277 | } |
||
278 |