Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
trend-andy-pan committed Sep 27, 2019
2 parents fe67783 + 54aae90 commit b8a3474
Show file tree
Hide file tree
Showing 101 changed files with 8,419 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
62 changes: 62 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
APP_NAME=Docker-ELKonLaravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=8080

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

# E.L.K. setting
ELK_VERSION=6.4.0

# Elasticsearch
ES_HOST=example-elasticsearch
ES_PORT1=9200
ES_PORT2=9300

# Logstash
LS_HOST=example-logstash
LS_PORT1=5000
LS_PORT2=9600

# Kibana
KB_HOST=example-kibana
KB_PORT=5601
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
8 changes: 8 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#remove Laravel base URL /public/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

RewriteRule . - [E=no-gzip:1]
16 changes: 16 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
php:
preset: laravel
enabled:
- alpha_ordered_imports
disabled:
- length_ordered_imports
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM 1and1internet/ubuntu-16-apache-php-7.2

# install phpredis function
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-get install -y php7.2-redis

EXPOSE 8080

WORKDIR /var/www/html
6 changes: 6 additions & 0 deletions ELK/logstash/config/logstash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
## Default Logstash configuration from logstash-docker.
## from https://github.com/elastic/logstash-docker/blob/master/build/logstash/config/logstash-oss.yml
#
http.host: "example-logstash"
path.config: /usr/share/logstash/pipeline
1 change: 1 addition & 0 deletions ELK/logstash/inputFile/log-2019-09-26.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[2019-09-16 07:49:14] Docker-ELKonLaravel.INFO: Hello Word!
32 changes: 32 additions & 0 deletions ELK/logstash/pipeline/logstash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
input {
tcp {
port => 5000
}

file {
type => "inputFile"
path => "/home/inputFile/*.log"
start_position => "beginning"
}
}

filter {
json {
source => "message"
remove_field => ["message"]
}
grok {
match => {
"message" =>
"\[%{TIMESTAMP_ISO8601:date}\] %{DATA:env}\.%{DATA:level}: %{GREEDYDATA:info}"
}
remove_field => ["message"]
}
}

output {
elasticsearch {
hosts => "${ES_HOST}:9200"
index => "example-elk"
}
}
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Docker-ELKonLaravel
E.L.K. example for PHP laravel via docker.

## 如何使用

1. 安裝 Docker

[官方安裝文件](https://docs.docker.com/install/)

2. 產生 環境變數
```bash
$ cp .env.example .env
```

3. 啟動
```bash
$ make dev
```

3. 安裝 PHP 相關套件
```bash
$ make install
```

4. 等待 E.L.K. 相關環境執行完畢 (約 1 ~ 5 分鐘)

5. 進入 Kibana 查看網站是否正常執行 <br>
`http://127.0.0.1:{KB_PORT}/`

KB_PORT 預設值: 5601

6. `Management` 分頁 找到 Kibana `Index Patterns` 連結

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_01.png)

7. 設定 E.L.K. index 資訊

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_02.png)

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_03.png)

8. `Discover` 分頁 即可看到相關資訊。

![image](https://github.com/andykuen/Docker-ELKonLaravel/blob/master/assets/images/kibana_04.png)

## 新增一筆資料

### URL
[`POST`] `http://127.0.0.1:{APP_PORT}/api/log`

### BODY (application/json)
```JSON
{
"msg": "你想要的內容"
}
```
42 changes: 42 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
51 changes: 51 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}
32 changes: 32 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
Loading

0 comments on commit b8a3474

Please sign in to comment.