Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into departure-rsync
Browse files Browse the repository at this point in the history
# Conflicts:
#	controllers/TaskController.php
  • Loading branch information
littlehz committed May 15, 2016
2 parents a5c1590 + 1768402 commit 0b0e118
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
/config/local.php
tests/_output/*
.idea/
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM php:apache

RUN apt-get update && apt-get install -y gettext-base libmcrypt-dev libicu-dev \
zlib1g-dev unzip git subversion ssh ansible && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install bcmath intl mbstring mcrypt mysqli opcache pdo_mysql
RUN a2enmod rewrite

COPY ./ /opt/walle-web
COPY docker/php.ini /usr/local/etc/php/conf.d/walle-web.ini
COPY docker/apache2.conf /etc/apache2/apache2.conf
COPY docker/entrypoint.sh /entrypoint.sh

WORKDIR /opt/walle-web
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer
RUN composer install --prefer-dist --no-dev --optimize-autoloader -vvvv
RUN chmod +x /entrypoint.sh && \
chown -R www-data:www-data /opt/walle-web

EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
23 changes: 12 additions & 11 deletions config/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,28 @@
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=127.0.0.1;dbname=walle',
'username' => 'root',
'password' => '',
'dsn' => isset($_ENV['WALLE_DB_DSN']) ? $_ENV['WALLE_DB_DSN'] : 'mysql:host=127.0.0.1;dbname=walle',
'username' => isset($_ENV['WALLE_DB_USER']) ? $_ENV['WALLE_DB_USER'] : 'root',
'password' => isset($_ENV['WALLE_DB_PASS']) ? $_ENV['WALLE_DB_PASS'] : '',
],
'mail' => [
'transport' => [
'host' => 'smtp.exmail.qq.com', # smtp 发件地址
'username' => '[email protected]', # smtp 发件用户名
'password' => 'K84erUuxg1bHqrfD', # smtp 发件人的密码
'port' => 25, # smtp 端口
'encryption' => 'tls', # smtp 协议
'host' => isset($_ENV['WALLE_MAIL_HOST']) ? $_ENV['WALLE_MAIL_HOST'] : 'smtp.exmail.qq.com', # smtp 发件地址
'username' => isset($_ENV['WALLE_MAIL_USER']) ? $_ENV['WALLE_MAIL_USER'] : '[email protected]', # smtp 发件用户名
'password' => isset($_ENV['WALLE_MAIL_PASS']) ? $_ENV['WALLE_MAIL_PASS'] : 'K84erUuxg1bHqrfD', # smtp 发件人的密码
'port' => isset($_ENV['WALLE_MAIL_PORT']) ? $_ENV['WALLE_MAIL_PORT'] : 25, # smtp 端口
'encryption' => isset($_ENV['WALLE_MAIL_ENCRYPTION']) ? $_ENV['WALLE_MAIL_ENCRYPTION'] : 'tls', # smtp 协议
],
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['[email protected]' => '花满树出品'], # smtp 发件用户名(须与mail.transport.username一致)
'from' => [
(isset($_ENV['WALLE_MAIL_EMAIL']) ? $_ENV['WALLE_MAIL_EMAIL'] : '[email protected]') => (isset($_ENV['WALLE_MAIL_NAME']) ? $_ENV['WALLE_MAIL_NAME'] : '花满树出品'),
], # smtp 发件用户名(须与mail.transport.username一致)
],
],
'request' => [
'cookieValidationKey' => 'PdXWDAfV5-gPJJWRar5sEN71DN0JcDRV',
],
],
'language' => 'zh-CN', // zh-CN => 中文, en => English
'language' => isset($_ENV['WALLE_LANGUAGE']) ? $_ENV['WALLE_LANGUAGE'] : 'zh-CN', // zh-CN => 中文, en => English
];

4 changes: 2 additions & 2 deletions config/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
],

// *******操作日志目录*******
'log.dir' => '/tmp/walle/',
'log.dir' => isset($_ENV['WALLE_LOG_PATH']) ? $_ENV['WALLE_LOG_PATH'] : '/tmp/walle/',
// *******Ansible Hosts 主机列表目录*******
'ansible_hosts.dir' => realpath(__DIR__ . '/../runtime') . '/ansible_hosts/',
'ansible_hosts.dir' => isset($_ENV['WALLE_ANSIBLE_HOSTS_DIR']) ? $_ENV['WALLE_ANSIBLE_HOSTS_DIR'] : realpath(__DIR__ . '/../runtime') . '/ansible_hosts/',
// *******指定公司邮箱后缀*******
'mail-suffix' => [
'*', # 支持多个
Expand Down
9 changes: 4 additions & 5 deletions controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
use app\components\Controller;
use app\models\Task;
use app\models\Project;
use app\models\User;
use app\models\Group;
use app\components\Repo;

class TaskController extends Controller {

protected $task;

/**
* 我的上线列表
*
*
* @param int $page
* @param int $size
* @return string
Expand All @@ -40,10 +38,10 @@ public function actionIndex($page = 1, $size = 10) {
$list->andWhere(['or', "commit_id like '%" . $kw . "%'", "title like '%" . $kw . "%'"]);
}
$tasks = $list->orderBy('id desc');
$list = $tasks->offset(($page - 1) * $size)->limit(10)
$list = $tasks->offset(($page - 1) * $size)->limit($size)
->asArray()->all();

$pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => 10]);
$pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => $size]);
return $this->render('list', [
'list' => $list,
'pages' => $pages,
Expand Down Expand Up @@ -71,6 +69,7 @@ public function actionSubmit($projectId = null) {
}

$task = new Task();

$conf = Project::getConf($projectId);
if (!$conf) {
throw new \Exception(yii::t('task', 'unknown project'));
Expand Down
51 changes: 51 additions & 0 deletions docker/apache2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Mutex file:/var/lock/apache2 default
PidFile /var/run/apache2/apache2.pid
Timeout 600
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 75
User www-data
Group www-data
HostnameLookups Off
ErrorLog /proc/self/fd/2
LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Listen 80

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /opt/walle-web/web/>
AllowOverride All
Require all granted
</Directory>

DocumentRoot /opt/walle-web/web

AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog /proc/self/fd/1 combined

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

DirectoryIndex index.php index.html

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
6 changes: 6 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e

/opt/walle-web/yii walle/setup --interactive=0

exec $@
7 changes: 7 additions & 0 deletions docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[PHP]
display_errors = On
short_open_tag = Off
max_execution_time = 600

[Date]
date.timezone = Asia/Shanghai
6 changes: 3 additions & 3 deletions views/task/select-project.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="widget-main padding-6 no-padding-left no-padding-right">
<?php foreach ($projects as $project) { ?>
<?php if ($project['level'] == Project::LEVEL_TEST) { ?>
<a class="btn btn-inline btn-warning" style="min-width:120px;margin:auto auto 20px 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<a class="btn btn-inline btn-info" style="min-width:120px;margin:auto auto 20px 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<?php } ?>
<?php } ?>
</div>
Expand All @@ -45,7 +45,7 @@
<div class="widget-main padding-6 no-padding-left no-padding-right">
<?php foreach ($projects as $project) { ?>
<?php if ($project['level'] == Project::LEVEL_SIMU) { ?>
<a class="btn btn-inline btn-warning" style="min-width:120px;margin-left: 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<a class="btn btn-inline btn-warning" style="min-width:120px;margin: auto auto 20px 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<?php } ?>
<?php } ?>
</div>
Expand All @@ -68,7 +68,7 @@
<div class="widget-main padding-6 no-padding-left no-padding-right">
<?php foreach ($projects as $project) { ?>
<?php if ($project['level'] == Project::LEVEL_PROD) { ?>
<a class="btn btn-inline btn-warning" style="min-width:120px;margin-left: 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<a class="btn btn-inline btn-success" style="min-width:120px;margin: auto auto 20px 40px;" href="<?= Url::to("@web/task/submit?projectId={$project['id']}") ?>"><?= $project['name'] ?></a>
<?php } ?>
<?php } ?>
</div>
Expand Down

0 comments on commit 0b0e118

Please sign in to comment.