Skip to content

Commit c3ef908

Browse files
Added more component selection (#9)
Co-authored-by: 李铭昕 <[email protected]>
1 parent d44f395 commit c3ef908

File tree

10 files changed

+257
-14
lines changed

10 files changed

+257
-14
lines changed

.github/workflows/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Default Dockerfile
2+
#
3+
# @link https://www.hyperf.io
4+
# @document https://hyperf.wiki
5+
6+
# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
7+
8+
FROM hyperf/hyperf:7.4-alpine-v3.11-cli
9+
LABEL maintainer="Hyperf Developers <[email protected]>" version="1.0" license="MIT" app.name="Hyperf"
10+
11+
##
12+
# ---------- env settings ----------
13+
##
14+
# --build-arg timezone=Asia/Shanghai
15+
ARG timezone
16+
17+
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
18+
COMPOSER_VERSION=1.10.10 \
19+
APP_ENV=prod \
20+
SCAN_CACHEABLE=(true)
21+
22+
# update
23+
RUN set -ex \
24+
# install composer
25+
&& cd /tmp \
26+
&& wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
27+
&& chmod u+x composer.phar \
28+
&& mv composer.phar /usr/local/bin/composer \
29+
# show php version and extensions
30+
&& php -v \
31+
&& php -m \
32+
&& php --ri swoole \
33+
# ---------- some config ----------
34+
&& cd /etc/php7 \
35+
# - config PHP
36+
&& { \
37+
echo "upload_max_filesize=128M"; \
38+
echo "post_max_size=128M"; \
39+
echo "memory_limit=1G"; \
40+
echo "date.timezone=${TIMEZONE}"; \
41+
} | tee conf.d/99_overrides.ini \
42+
# - config timezone
43+
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
44+
&& echo "${TIMEZONE}" > /etc/timezone \
45+
# ---------- clear works ----------
46+
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
47+
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
48+
49+
WORKDIR /opt/www
50+
51+
# Composer Cache
52+
# COPY ./composer.* /opt/www/
53+
# RUN composer install --no-dev --no-scripts
54+
55+
COPY . /opt/www
56+
RUN print "\n" | composer install -o && php bin/hyperf.php
57+
58+
EXPOSE 9501
59+
60+
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"]

.github/workflows/build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Build Docker
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v2
11+
- name: Build
12+
run: cp -rf .github/workflows/Dockerfile . && docker build -t hyperf .

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Release
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: Release ${{ github.ref }}
24+
draft: false
25+
prerelease: false

installer/OptionalPackages.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function finalizePackage(): void
252252
*/
253253
public function processAnswer(array $question, $answer): bool
254254
{
255-
if (is_numeric($answer) && isset($question['options'][$answer])) {
255+
if (isset($question['options'][$answer])) {
256256
// Add packages to install
257257
if (isset($question['options'][$answer]['packages'])) {
258258
foreach ($question['options'][$answer]['packages'] as $packageName) {
@@ -398,7 +398,7 @@ private function askQuestion(array $question, $defaultOption)
398398
$defaultText = $defaultOption;
399399
foreach ($question['options'] as $key => $option) {
400400
$defaultText = ($key === $defaultOption) ? $option['name'] : $defaultText;
401-
$ask[] = sprintf(" [<comment>%d</comment>] %s\n", $key, $option['name']);
401+
$ask[] = sprintf(" [<comment>%s</comment>] %s\n", $key, $option['name']);
402402
}
403403
if ($question['required'] !== true) {
404404
$ask[] = " [<comment>n</comment>] None of the above\n";
@@ -420,6 +420,10 @@ private function askQuestion(array $question, $defaultOption)
420420
if (is_numeric($answer) && isset($question['options'][(int) $answer])) {
421421
return (int) $answer;
422422
}
423+
// Handle string options
424+
if (isset($question['options'][$answer])) {
425+
return $answer;
426+
}
423427
// Search for package
424428
if ($question['custom-package'] === true && preg_match(self::PACKAGE_REGEX, $answer, $match)) {
425429
$packageName = $match['name'];

installer/config.php

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
'hyperf/async-queue' => [
1818
'version' => '~2.0.0',
1919
],
20+
'hyperf/database' => [
21+
'version' => '~2.0.0',
22+
],
23+
'hyperf/db-connection' => [
24+
'version' => '~2.0.0',
25+
],
2026
'hyperf/model-cache' => [
2127
'version' => '~2.0.0',
2228
],
@@ -26,6 +32,9 @@
2632
'hyperf/json-rpc' => [
2733
'version' => '~2.0.0',
2834
],
35+
'hyperf/redis' => [
36+
'version' => '~2.0.0',
37+
],
2938
'hyperf/rpc' => [
3039
'version' => '~2.0.0',
3140
],
@@ -50,6 +59,9 @@
5059
'hyperf/config-aliyun-acm' => [
5160
'version' => '~2.0.0',
5261
],
62+
'hyperf/config-etcd' => [
63+
'version' => '~2.0.0',
64+
],
5365
'hyperf/tracer' => [
5466
'version' => '~2.0.0',
5567
],
@@ -60,14 +72,49 @@
6072
'require-dev' => [
6173
],
6274
'questions' => [
75+
'database' => [
76+
'question' => 'Do you want to use Database (MySQL Client) ?',
77+
'default' => 'y',
78+
'required' => false,
79+
'custom-package' => true,
80+
'options' => [
81+
'y' => [
82+
'name' => 'yes',
83+
'packages' => [
84+
'hyperf/database',
85+
'hyperf/db-connection',
86+
],
87+
'resources' => [
88+
'resources/database/databases.php' => 'config/autoload/databases.php',
89+
],
90+
],
91+
],
92+
],
93+
'redis' => [
94+
'question' => 'Do you want to use Redis Client ?',
95+
'default' => 'y',
96+
'required' => false,
97+
'custom-package' => true,
98+
'options' => [
99+
'y' => [
100+
'name' => 'yes',
101+
'packages' => [
102+
'hyperf/redis',
103+
],
104+
'resources' => [
105+
'resources/database/redis.php' => 'config/autoload/redis.php',
106+
],
107+
],
108+
],
109+
],
63110
'rpc' => [
64111
'question' => 'Which RPC protocol do you want to use ?',
65112
'default' => 'n',
66113
'required' => false,
67114
'custom-package' => true,
68115
'options' => [
69116
1 => [
70-
'name' => 'JSON-RPC with Service Governance',
117+
'name' => 'JSON RPC with Service Governance',
71118
'packages' => [
72119
'hyperf/json-rpc',
73120
'hyperf/rpc',
@@ -79,7 +126,7 @@
79126
],
80127
],
81128
2 => [
82-
'name' => 'JSON-RPC',
129+
'name' => 'JSON RPC',
83130
'packages' => [
84131
'hyperf/json-rpc',
85132
'hyperf/rpc',
@@ -125,6 +172,16 @@
125172
'resources/config_center/aliyun_acm.php' => 'config/autoload/aliyun_acm.php',
126173
],
127174
],
175+
3 => [
176+
'name' => 'ETCD',
177+
'packages' => [
178+
'hyperf/config-etcd',
179+
],
180+
'resources' => [
181+
'resources/config_center/etcd.php' => 'config/autoload/etcd.php',
182+
'resources/config_center/config_etcd.php' => 'config/autoload/config_etcd.php',
183+
],
184+
],
128185
],
129186
],
130187
'constants' => [
@@ -134,7 +191,7 @@
134191
'force' => true,
135192
'custom-package' => false,
136193
'options' => [
137-
1 => [
194+
'y' => [
138195
'name' => 'yes',
139196
'packages' => [
140197
'hyperf/constants',
@@ -153,7 +210,7 @@
153210
'force' => true,
154211
'custom-package' => true,
155212
'options' => [
156-
1 => [
213+
'y' => [
157214
'name' => 'yes',
158215
'packages' => [
159216
'hyperf/async-queue',
@@ -162,6 +219,7 @@
162219
'resources/async_queue/async_queue.php' => 'config/autoload/async_queue.php',
163220
'resources/async_queue/AsyncQueueConsumer.php' => 'app/Process/AsyncQueueConsumer.php',
164221
'resources/async_queue/QueueHandleListener.php' => 'app/Listener/QueueHandleListener.php',
222+
'resources/database/redis.php' => 'config/autoload/redis.php',
165223
],
166224
],
167225
],
@@ -173,7 +231,7 @@
173231
'force' => true,
174232
'custom-package' => true,
175233
'options' => [
176-
1 => [
234+
'y' => [
177235
'name' => 'yes',
178236
'packages' => [
179237
'hyperf/amqp',
@@ -191,14 +249,15 @@
191249
'force' => true,
192250
'custom-package' => true,
193251
'options' => [
194-
1 => [
252+
'y' => [
195253
'name' => 'yes',
196254
'packages' => [
197255
'hyperf/model-cache',
198256
],
199257
'resources' => [
200258
'resources/model_cache/Model.php' => 'app/Model/Model.php',
201259
'resources/model_cache/databases.php' => 'config/autoload/databases.php',
260+
'resources/database/redis.php' => 'config/autoload/redis.php',
202261
],
203262
],
204263
],
@@ -210,13 +269,12 @@
210269
'force' => true,
211270
'custom-package' => true,
212271
'options' => [
213-
1 => [
272+
'y' => [
214273
'name' => 'yes',
215274
'packages' => [
216275
'hyperf/elasticsearch',
217276
],
218277
'resources' => [
219-
// 'resources/elasticsearch/elasticsearch.php' => 'config/autoload/elasticsearch.php',
220278
],
221279
],
222280
],
@@ -228,7 +286,7 @@
228286
'force' => true,
229287
'custom-package' => true,
230288
'options' => [
231-
1 => [
289+
'y' => [
232290
'name' => 'yes',
233291
'packages' => [
234292
'hyperf/tracer',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
return [
13+
'enable' => false,
14+
'packer' => Hyperf\Utils\Packer\JsonPacker::class,
15+
'use_standalone_process' => true,
16+
'namespaces' => [
17+
'/application',
18+
],
19+
'mapping' => [
20+
'/application/test' => 'test',
21+
],
22+
'interval' => 5,
23+
];
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
return [
13+
'uri' => 'http://127.0.0.1:2379',
14+
'version' => 'v3beta',
15+
'options' => [
16+
'timeout' => 10,
17+
],
18+
];
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
return [
13+
'default' => [
14+
'driver' => env('DB_DRIVER', 'mysql'),
15+
'host' => env('DB_HOST', 'localhost'),
16+
'port' => env('DB_PORT', 3306),
17+
'database' => env('DB_DATABASE', 'hyperf'),
18+
'username' => env('DB_USERNAME', 'root'),
19+
'password' => env('DB_PASSWORD', ''),
20+
'charset' => env('DB_CHARSET', 'utf8mb4'),
21+
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
22+
'prefix' => env('DB_PREFIX', ''),
23+
'pool' => [
24+
'min_connections' => 1,
25+
'max_connections' => 10,
26+
'connect_timeout' => 10.0,
27+
'wait_timeout' => 3.0,
28+
'heartbeat' => -1,
29+
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
30+
],
31+
'commands' => [
32+
'gen:model' => [
33+
'path' => 'app/Model',
34+
'force_casts' => true,
35+
'inheritance' => 'Model',
36+
'uses' => '',
37+
'table_mapping' => [],
38+
],
39+
],
40+
],
41+
];
File renamed without changes.

0 commit comments

Comments
 (0)