Skip to content

Commit

Permalink
Added Filament Demo, along with improvements to the Docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioassuncao committed Jan 10, 2024
1 parent 9ad49b3 commit c3d9283
Show file tree
Hide file tree
Showing 225 changed files with 15,258 additions and 2,431 deletions.
69 changes: 44 additions & 25 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
FROM php:8.3-alpine

LABEL maintainer="Fábio Assunção <[email protected]>"

# Install necessary tools
RUN apk --no-cache add \
bash \
curl \
libzip-dev \
unzip

# Install php-extension-installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
FROM alpine:latest

WORKDIR /var/www/html/

# Essentials
RUN echo "UTC" > /etc/timezone
RUN apk add --no-cache zip unzip curl sqlite bash && \
sed -i 's/bin\/ash/bin\/bash/g' /etc/passwd

# Installing PHP
RUN apk add --no-cache php83 \
php83-common \
php83-pdo \
php83-opcache \
php83-zip \
php83-phar \
php83-iconv \
php83-cli \
php83-curl \
php83-openssl \
php83-mbstring \
php83-tokenizer \
php83-fileinfo \
php83-json \
php83-xml \
php83-xmlwriter \
php83-simplexml \
php83-dom \
php83-pdo_mysql \
php83-pdo_sqlite \
php83-tokenizer \
php83-pecl-redis \
php83-intl \
php83-exif \
php83-pcntl \
php83-sockets

RUN ln -s /usr/bin/php83 /usr/bin/php

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# Install required PHP extensions
RUN install-php-extensions pcntl sockets

# Set the working directory
WORKDIR /var/www

# Copy application files
COPY . /var/www

# Download and set up FrankenPHP
ADD https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-x86_64 /usr/local/bin/frankenphp
RUN chmod +x /usr/local/bin/frankenphp

# Install Composer dependencies
# Building process
COPY . /var/www/html

RUN composer install --no-dev
RUN chown -R nobody:nobody /var/www/html/storage

# Entrypoint command
ENTRYPOINT ["php", "artisan", "octane:start", "--server=frankenphp", "--port=8000", "--workers=16", "--host=0.0.0.0"]
EXPOSE 8000
ENTRYPOINT ["php", "-d", "variables_order=EGPCS", "artisan", "octane:start", "--server=frankenphp", "--host=0.0.0.0", "--port=8000"]
2 changes: 0 additions & 2 deletions .docker/storage/mysql/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions .docker/storage/redis/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
Expand Down
13 changes: 4 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_NAME="Filament K8s Demo"
APP_ENV=local
APP_KEY=base64:IbDmL/UMRI+JIni82m3Vs19+/+jc/GEdEkXvOEWA+nA=
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost:8000

Expand Down Expand Up @@ -43,17 +43,12 @@ 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_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_APP_NAME="${APP_NAME}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
14 changes: 4 additions & 10 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
.styleci.yml export-ignore
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/build
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

/caddy
frankenphp
frankenphp-worker.php

.docker/volumes/mysql
.docker/volumes/redis
14 changes: 14 additions & 0 deletions .styleci.yml
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
21 changes: 21 additions & 0 deletions LICENSE.md
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.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Laravel k8s
# Laravel Filament + k8s

Project demo for my Laravel and Kubernetes workshop with deployment on Azure Kubernetes Service and DigitalOcean Kubernetes.

Expand All @@ -9,10 +9,13 @@ This project is a simple demo. I chose to use FrankenPHP with an app server, but
* PHP 8.3
* [Laravel](https://laravel.com/)
* [Laravel Octane](https://laravel.com/docs/10.x/octane)
* [Laravel Filament](https://filamentphp.com/)
* [FrankenPHP](https://frankenphp.dev/)
* [AKS](https://azure.microsoft.com/pt-br/products/kubernetes-service)
* [DOKS](https://www.digitalocean.com/products/kubernetes)

![Filament Demo](./screenshot.png)

## Upcoming Meetings

This repository is the initial part of something larger. We will have a project with services developed in NodeJS (NestJS), Go, and PHP (Laravel), all containerized and deployed in a Kubernetes cluster.
Expand Down
12 changes: 8 additions & 4 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @return void
*/
protected function schedule(Schedule $schedule): void
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
//
}

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

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

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum OrderStatus: string implements HasColor, HasLabel
{
case New = 'new';

case Processing = 'processing';

case Shipped = 'shipped';

case Delivered = 'delivered';

case Cancelled = 'cancelled';

public function getLabel(): string
{
return match ($this) {
self::New => 'New',
self::Processing => 'Processing',
self::Shipped => 'Shipped',
self::Delivered => 'Delivered',
self::Cancelled => 'Cancelled',
};
}

public function getColor(): string | array | null
{
return match ($this) {
self::New => 'gray',
self::Processing => 'warning',
self::Shipped, self::Delivered => 'success',
self::Cancelled => 'danger',
};
}
}
15 changes: 13 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
Expand All @@ -20,8 +29,10 @@ class Handler extends ExceptionHandler

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register(): void
public function register()
{
$this->reportable(function (Throwable $e) {
//
Expand Down
23 changes: 23 additions & 0 deletions app/Filament/App/Pages/RegisterTeam.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Filament\App\Pages;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;

class RegisterTeam extends RegisterTenant
{
public static function getLabel(): string
{
return 'New team';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')->required(),
]);
}
}
12 changes: 12 additions & 0 deletions app/Filament/App/Pages/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\App\Pages;

use Filament\Pages\Page;

class Settings extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.pages.settings';
}
Loading

0 comments on commit c3d9283

Please sign in to comment.