-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5193c4d
commit 05caaa5
Showing
39 changed files
with
1,873 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.yaml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
APP_ENV=production | ||
|
||
# Debug mode set to TRUE disables view caching and enables higher verbosity. | ||
DEBUG=true | ||
VERBOSITY_LEVEL=verbose | ||
|
||
# Available levels: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY | ||
MONOLOG_DEFAULT_LEVEL=DEBUG | ||
|
||
QUEUE_DRIVER=roadrunner | ||
QUEUE_PIPELINE=memory | ||
|
||
CACHE_STORAGE=local | ||
|
||
# Packagist repository names to follow (comma separated) | ||
PACKAGIST_REPOSITORIES= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Docker Dev Image CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.GHCR_LOGIN }} | ||
password: ${{ secrets.GHCR_PASSWORD }} | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ./ | ||
file: ./docker/Dockerfile | ||
push: true | ||
build-args: | ||
APP_VERSION=dev | ||
tags: | ||
ghcr.io/metrixio/docker:dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
build-release: | ||
if: "!github.event.release.prerelease" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: 'Get Previous tag' | ||
id: previoustag | ||
uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
with: | ||
fallback: v0.1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.GHCR_LOGIN }} | ||
password: ${{ secrets.GHCR_PASSWORD }} | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ./ | ||
file: ./docker/Dockerfile | ||
push: true | ||
build-args: | ||
APP_VERSION=${{ steps.previoustag.outputs.tag }} | ||
tags: | ||
ghcr.io/metrixio/docker:latest, ghcr.io/metrixio/docker:${{ steps.previoustag.outputs.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea | ||
vendor | ||
runtime | ||
rr* | ||
spiral* | ||
.env | ||
.phpunit.result.cache | ||
.deptrac.cache | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '2.7' | ||
|
||
rpc: | ||
listen: tcp://127.0.0.1:6001 | ||
|
||
logs: | ||
level: info | ||
|
||
server: | ||
command: "php app.php" | ||
relay: pipes | ||
|
||
kv: | ||
local: | ||
driver: memory | ||
config: {} | ||
|
||
jobs: | ||
pool: | ||
num_workers: 2 | ||
|
||
service: | ||
collector: | ||
command: "php app.php collect:start" | ||
remain_after_exit: true | ||
restart_sec: 1 | ||
|
||
metrics: | ||
address: 0.0.0.0:2112 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
risky: false | ||
preset: psr12 | ||
enabled: | ||
# Risky Fixers | ||
# - declare_strict_types | ||
# - void_return | ||
- ordered_class_elements | ||
- linebreak_after_opening_tag | ||
- single_quote | ||
- no_blank_lines_after_phpdoc | ||
- unary_operator_spaces | ||
- no_useless_else | ||
- no_useless_return | ||
- trailing_comma_in_multiline_array | ||
finder: | ||
exclude: | ||
- "tests" | ||
- "public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Packagist metrics collector | ||
|
||
![packagist](https://user-images.githubusercontent.com/773481/209584409-3275bfa7-f131-44de-b4c1-341d4b0cd3d3.png) | ||
|
||
This tool lets you easily gather data about downloads from Packagist. | ||
|
||
It works with Prometheus and Grafana to collect data from Packagist, store it in Prometheus, and create visualizations | ||
with Grafana. You can use Grafana to customize the data you collect and create dashboards that fit your needs. | ||
|
||
We hope you find it helpful! | ||
|
||
## Dashboard | ||
|
||
![image](https://user-images.githubusercontent.com/773481/209584323-9f673696-f235-4737-b7ea-719da8c3ada3.png) | ||
|
||
## Usage | ||
|
||
Check out the documentation in the [dashboard](https://github.com/metrixio/dashboard) repository. That should give you | ||
all the details you need to get going. | ||
|
||
```dotenv | ||
# Packagist repository names to follow (comma separated) | ||
PACKAGIST_REPOSITORIES=... | ||
``` | ||
|
||
### Docker | ||
|
||
```yaml | ||
version: "3.7" | ||
|
||
services: | ||
docker-metrics: | ||
image: ghcr.io/metrixio/packagist:latest | ||
environment: | ||
PACKAGIST_REPOSITORIES: ... | ||
restart: on-failure | ||
|
||
prometheus: | ||
image: prom/prometheus | ||
volumes: | ||
- ./runtime/prometheus:/prometheus | ||
restart: always | ||
|
||
grafana: | ||
image: grafana/grafana | ||
depends_on: | ||
- prometheus | ||
ports: | ||
- 3000:3000 | ||
volumes: | ||
- ./runtime/grafana:/var/lib/grafana | ||
restart: always | ||
``` | ||
### Local server | ||
```bash | ||
composer create-project metrixio/packagist | ||
``` | ||
|
||
Define the repositories you want to track in `.env` file | ||
|
||
```dotenv | ||
PACKAGIST_REPOSITORIES=spiral/framework,... | ||
``` | ||
|
||
Once the project is installed and configured you can start application server: | ||
|
||
```bash | ||
./rr serve | ||
``` | ||
|
||
Metrics will be available on http://127.0.0.1:2112. | ||
|
||
> **Note**: | ||
> To fix unable to open metrics page, change metrics address in RoadRunner config file to `127.0.0.1:2112`. | ||
----- | ||
|
||
The package is built with some of the best tools out there for PHP. It's powered | ||
by [Spiral Framework](https://github.com/spiral/framework/), which makes it super fast and efficient, and it | ||
uses [RoadRunner](https://github.com/roadrunner-server/roadrunner) as the server, which is a really great tool for | ||
collecting metrics data for Prometheus. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Application\Kernel; | ||
use App\Application\Service\ErrorHandler\Handler; | ||
|
||
// If you forgot to configure some of this in your php.ini file, | ||
// then don't worry, we will set the standard environment | ||
// settings for you. | ||
|
||
\mb_internal_encoding('UTF-8'); | ||
\error_reporting(E_ALL | E_STRICT ^ E_DEPRECATED); | ||
\ini_set('display_errors', 'stderr'); | ||
|
||
// Register Composer's auto loader. | ||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
|
||
// Initialize shared container, bindings, directories and etc. | ||
$app = Kernel::create( | ||
directories: ['root' => __DIR__], | ||
)->run(); | ||
|
||
if ($app === null) { | ||
exit(255); | ||
} | ||
|
||
$code = (int)$app->serve(); | ||
exit($code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Spiral\Cache\Storage\ArrayStorage; | ||
use Spiral\Cache\Storage\FileStorage; | ||
|
||
return [ | ||
'default' => env('CACHE_STORAGE', 'local'), | ||
'aliases' => [ | ||
'repositories' => 'local', | ||
], | ||
'storages' => [ | ||
'local' => [ | ||
'type' => 'roadrunner', | ||
'driver' => 'local', | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Monolog\Handler\ErrorLogHandler; | ||
use Monolog\Logger; | ||
|
||
return [ | ||
'default' => 'roadrunner', | ||
'globalLevel' => Logger::toMonologLevel(env('MONOLOG_DEFAULT_LEVEL', Logger::DEBUG)), | ||
'handlers' => [ | ||
'roadrunner' => [ | ||
\Spiral\RoadRunnerBridge\Logger\Handler::class, | ||
] | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
'repositories' => [], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Spiral\RoadRunner\Jobs\Queue\MemoryCreateInfo; | ||
use Spiral\RoadRunnerBridge\Queue\Queue; | ||
|
||
return [ | ||
'default' => env('QUEUE_DRIVER', 'roadrunner'), | ||
'aliases' => [], | ||
'connections' => [ | ||
'roadrunner' => [ | ||
'driver' => 'roadrunner', | ||
'default' => env('QUEUE_PIPELINE', 'memory'), | ||
'pipelines' => [ | ||
'memory' => [ | ||
'connector' => new MemoryCreateInfo('local'), | ||
'consume' => true, | ||
], | ||
], | ||
], | ||
], | ||
|
||
'registry' => [ | ||
'handlers' => [], | ||
], | ||
|
||
'interceptors' => [ | ||
'push' => [], | ||
'consume' => [ | ||
\Spiral\Queue\Interceptor\Consume\ErrorHandlerInterceptor::class, | ||
], | ||
], | ||
]; |
Oops, something went wrong.