-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 24f6563
Showing
312 changed files
with
26,423 additions
and
0 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,18 @@ | ||
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 | ||
|
||
[docker-compose.yml] | ||
indent_size = 4 |
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,49 @@ | ||
APP_NAME="Filament Demo" | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://127.0.0.1:8000 | ||
|
||
LOG_CHANNEL=stack | ||
LOG_DEPRECATIONS_CHANNEL=null | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=sqlite | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
FILESYSTEM_DRIVER=local | ||
QUEUE_CONNECTION=sync | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
MEMCACHED_HOST=127.0.0.1 | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=smtp | ||
MAIL_HOST=mailhog | ||
MAIL_PORT=1025 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS=null | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
AWS_USE_PATH_STYLE_ENDPOINT=false | ||
|
||
FLARE_KEY= | ||
|
||
PUSHER_APP_ID= | ||
PUSHER_APP_KEY= | ||
PUSHER_APP_SECRET= | ||
PUSHER_APP_CLUSTER=mt1 | ||
|
||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
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,5 @@ | ||
* text=auto | ||
*.css linguist-vendored | ||
*.scss linguist-vendored | ||
*.js linguist-vendored | ||
CHANGELOG.md export-ignore |
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,24 @@ | ||
name: Check & fix styling | ||
|
||
on: [push] | ||
|
||
jobs: | ||
pint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
- name: Install dependencies | ||
run: composer install --no-interaction | ||
- name: Run Pint | ||
run: ./vendor/bin/pint | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Fix styling |
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 @@ | ||
/node_modules | ||
/public/hot | ||
/public/build | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
docker-compose.override.yml | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
/.idea | ||
/.vscode |
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,22 @@ | ||
tasks: | ||
- name: Setup environment and launch | ||
init: | | ||
cp .env.example .env | ||
sed -i "s#APP_URL=http://127.0.0.1:8000#APP_URL=$(gp url 8000)#g" .env | ||
composer install --ignore-platform-reqs | ||
php artisan key:generate | ||
php artisan storage:link | ||
touch database/database.sqlite | ||
php artisan migrate:fresh --seed | ||
php artisan serve | ||
# Configure vscode | ||
vscode: | ||
extensions: | ||
- bmewburn.vscode-intelephense-client | ||
- ms-azuretools.vscode-docker | ||
- ecmel.vscode-html-css | ||
- MehediDracula.php-namespace-resolver | ||
- Equinusocio.vsc-community-material-theme | ||
- EditorConfig.EditorConfig | ||
- streetsidesoftware.code-spell-checker |
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,14 @@ | ||
php: | ||
preset: laravel | ||
version: 8 | ||
disabled: | ||
- no_unused_imports | ||
finder: | ||
not-name: | ||
- index.php | ||
- server.php | ||
js: | ||
finder: | ||
not-name: | ||
- webpack.mix.js | ||
css: true |
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,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) Filament | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,68 @@ | ||
# Zerops x Filament - production setup | ||
|
||
WORK IN PROGRESS - development enviroment | ||
|
||
[Filament](https://filamentphp.com) is a collection of beautiful full-stack components. This recipe showcasing how to run production version in Zerops. It's based on [Filament Demo](https://github.com/filamentphp/demo) and | ||
icludes all the advanced functionality — session and cache | ||
stored in Redis and files stored in Object Storage, this makes it perfectly suitable for production of any size. | ||
|
||
<br/> | ||
|
||
## Deploy on Zerops | ||
|
||
You can either click the deploy button to deploy directly on Zerops, or manually copy | ||
the [import yaml](https://github.com/zeropsio/recipe-laravel-jetstream/blob/main/zerops-project-import.yml) to the | ||
import dialog in the Zerops app. | ||
|
||
[![Deploy on Zerops](https://github.com/zeropsio/recipe-shared-assets/blob/main/deploy-button/green/deploy-button.svg)](https://app.zerops.io/recipe/laravel) | ||
|
||
<br/> | ||
|
||
## Recipe features | ||
|
||
- Filament running on a load balanced **Zerops PHP + Nginx** service | ||
- Zerops **PostgreSQL 16** service as database | ||
- Zerops KeyDB (**Redis**) service for session and cache | ||
- Zerops **Object Storage** (S3 compatible) service as file system | ||
- Proper setup for Laravel **cache**, **optimization**, and **database migrations** | ||
- Logs set up to use **syslog** and accessible through Zerops GUI | ||
- Utilization of Zerops built-in **environment variables** system | ||
|
||
[//]: # (- [Mailpit](https://github.com/axllent/mailpit) as **SMTP mock server**) | ||
[//]: # (- [Adminer](https://www.adminer.org) for **quick database management** tool) | ||
|
||
<br/> | ||
|
||
## Production vs. development | ||
|
||
Base of the recipe is ready for production, the difference comes down to: | ||
|
||
- Use highly available version of the PostgreSQL database (change `mode` from `NON_HA` to `HA` in recipe YAML, `db` | ||
service section) | ||
- Use at least two containers for Jetstream service to achieve high reliability and resilience (add `minContainers: 2` | ||
in recipe YAML, `app` service section) | ||
- Use production-ready third-party SMTP server instead of Mailpit (change `MAIL_` secret variables in recipe YAML `app` | ||
service) | ||
- Disable public access to Adminer or remove it altogether (remove service `adminer` from recipe YAML) | ||
|
||
<br/> | ||
|
||
## Changes made over the default installation | ||
|
||
If you want to modify your existing Filament app to efficiently run on Zerops, these are the general steps we | ||
took: | ||
|
||
- Add [zerops.yml](https://github.com/zeropsio/recipe-filament/blob/main/zerops.yml) to your repository, our | ||
example includes idempotent migrations, caching, and optimized build process | ||
- Setup health check. From Laravel 11 is by default setup by framework. | ||
- Add [league/flysystem-aws-s3-v3](https://github.com/zeropsio/recipe-filament/blob/main/composer.json#L14) to | ||
your composer.json to support Object Storage file system | ||
- Utilize | ||
Zerops [environment variables](https://github.com/zeropsio/recipe-filament/blob/main/zerops.yml#L25-L75) | ||
and [secrets](https://github.com/zeropsio/recipe-filament/blob/main/zerops-project-import.yml#L12-L16) to | ||
setup S3 for file system, Redis for cache and sessions, and trusted proxies to work with reverse proxy load balancer | ||
|
||
<br/> | ||
<br/> | ||
|
||
Need help setting your project up? Join [Zerops Discord community](https://discord.com/invite/WDvCZ54). |
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,100 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Database\Seeders\LocalImages; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Str; | ||
|
||
class GetRandomImages extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:get-random-images'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Get random images stored locally, so that the seed process can be fast.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
// Use an empty string to get random images | ||
// We could fine-tune with search terms, examples: 'nature', 'people', 'city', 'abstract', 'food', 'sports', 'technics', 'transport', 'animals' | ||
// This needs some deeper research to get the best results | ||
|
||
$schemas = [ | ||
['amount' => 40, 'size' => LocalImages::SIZE_200x200, 'terms' => ['']], | ||
['amount' => 40, 'size' => LocalImages::SIZE_1280x720, 'terms' => ['']], | ||
]; | ||
|
||
foreach ($schemas as $schema) { | ||
$this->getRandomImages($schema); | ||
} | ||
|
||
foreach ($schemas as $schema) { | ||
$this->removeDuplicates($schema); | ||
} | ||
} | ||
|
||
protected function getRandomImages($schema) | ||
{ | ||
['amount' => $amount, 'size' => $size, 'terms' => $terms] = $schema; | ||
|
||
$this->comment("Getting $amount random images of size $size, of topic: " . implode(', ', $terms)); | ||
|
||
File::deleteDirectory(database_path('seeders/local_images/' . $size)); | ||
|
||
$progressBar = $this->output->createProgressBar($amount); | ||
$progressBar->start(); | ||
|
||
foreach (range(1, $amount) as $i) { | ||
$url = "https://source.unsplash.com/{$size}/?img=1," . implode(',', $terms); | ||
$image = file_get_contents($url); | ||
|
||
File::ensureDirectoryExists(database_path('seeders/local_images/' . $size)); | ||
$filename = Str::uuid() . '.jpg'; | ||
|
||
File::put( | ||
database_path( | ||
path: "seeders/local_images/{$size}/{$filename}" | ||
), | ||
contents: $image | ||
); | ||
|
||
$progressBar->advance(); | ||
} | ||
|
||
$progressBar->finish(); | ||
|
||
$this->newLine(); | ||
$this->info('Done!'); | ||
} | ||
|
||
protected function removeDuplicates($schema) | ||
{ | ||
['size' => $size] = $schema; | ||
|
||
$allFiles = fn () => collect(File::files(database_path('seeders/local_images/' . $size))); | ||
|
||
$uniqueImageSet = $allFiles() | ||
->mapWithKeys(fn ($file) => [md5_file($file->getPathname()) => $file->getPathname()]) | ||
->values(); | ||
|
||
$allFiles() | ||
->map(fn ($file) => $file->getPathname()) | ||
->diff($uniqueImageSet) | ||
->each(fn ($file) => File::delete($file)); | ||
|
||
$this->info('Kept ' . $uniqueImageSet->count() . " unique files from size $size"); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* Define the application's command schedule. | ||
* | ||
* @return void | ||
*/ | ||
protected function schedule(Schedule $schedule) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
* | ||
* @return void | ||
*/ | ||
protected function commands() | ||
{ | ||
$this->load(__DIR__ . '/Commands'); | ||
|
||
require base_path('routes/console.php'); | ||
} | ||
} |
Oops, something went wrong.