Compare commits
15
Commits
91a538cef7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ed7b7d62e | ||
|
|
69dd740f80 | ||
|
|
f3d8a1d4ff | ||
|
|
a16005dcbc | ||
|
|
ba7df8c378 | ||
|
|
16ba5089e7 | ||
|
|
b6feb44470 | ||
|
|
095307a456 | ||
|
|
c59f760730 | ||
|
|
80f334d5bd | ||
|
|
b9d019d6de | ||
|
|
38c59d140a | ||
|
|
df35862de7 | ||
|
|
44d646f44b | ||
|
|
1a85d6e9a8 |
+7
-2
@@ -65,12 +65,17 @@ RUN mkdir -p bootstrap/cache storage/framework/views storage/framework/cache sto
|
|||||||
|
|
||||||
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||||
COPY docker/supervisord.conf /etc/supervisor.conf
|
COPY docker/supervisord.conf /etc/supervisor.conf
|
||||||
COPY docker/www.conf /usr/local/etc/php-fpm.d/www.conf
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
RUN echo "* * * * * php /app/artisan schedule:run >> /dev/null 2>&1" > /etc/crontabs/www-data
|
RUN chmod +x /entrypoint.sh \
|
||||||
|
&& printf '[www]\nlisten = 127.0.0.1:9000\nclear_env = no\npm.max_children = 20\npm.start_servers = 4\npm.min_spare_servers = 2\npm.max_spare_servers = 6\nrequest_terminate_timeout = 300s\n' > /usr/local/etc/php-fpm.d/zz-opencode.conf \
|
||||||
|
&& php-fpm -t \
|
||||||
|
&& nginx -t \
|
||||||
|
&& echo "* * * * * php /app/artisan schedule:run >> /dev/null 2>&1" > /etc/crontabs/www-data
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
STOPSIGNAL SIGQUIT
|
STOPSIGNAL SIGQUIT
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.conf"]
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.conf"]
|
||||||
|
|||||||
+1
-1
@@ -40,6 +40,6 @@ class Role extends SpatieRole
|
|||||||
}
|
}
|
||||||
public function permissions(): BelongsToMany
|
public function permissions(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Permission::class);
|
return $this->belongsToMany(Permission::class, 'role_has_permissions');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
-1
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Filament\Models\Contracts\FilamentUser;
|
||||||
|
use Filament\Panel;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@@ -10,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable implements FilamentUser
|
||||||
{
|
{
|
||||||
use HasApiTokens, HasFactory, Notifiable, HasRoles;
|
use HasApiTokens, HasFactory, Notifiable, HasRoles;
|
||||||
|
|
||||||
@@ -45,6 +47,11 @@ class User extends Authenticatable
|
|||||||
'password' => 'hashed', // Laravel 10+ soporta casting a hashed
|
'password' => 'hashed', // Laravel 10+ soporta casting a hashed
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function canAccessPanel(Panel $panel): bool
|
||||||
|
{
|
||||||
|
return $this->hasAnyRole(['Administrador', 'Super Admin']) || $this->hasPermissionTo('view_admin');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the roles associated with the user.
|
* Get the roles associated with the user.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Providers\Filament;
|
namespace App\Providers\Filament;
|
||||||
|
|
||||||
|
use App\Filament\Pages\GestionDashboard;
|
||||||
|
use App\Filament\Pages\GestionStockPage;
|
||||||
|
use App\Filament\Pages\PuntoVenta;
|
||||||
|
use App\Filament\Pages\SettingPage;
|
||||||
use App\Filament\Resources\ReporteventasResource\Pages\ReporteVentas;
|
use App\Filament\Resources\ReporteventasResource\Pages\ReporteVentas;
|
||||||
use Filament\Http\Middleware\Authenticate;
|
use Filament\Http\Middleware\Authenticate;
|
||||||
use Filament\Http\Middleware\AuthenticateSession;
|
|
||||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
|
||||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
|
||||||
use Filament\Pages;
|
use Filament\Pages;
|
||||||
use Filament\Panel;
|
use Filament\Panel;
|
||||||
use Filament\PanelProvider;
|
use Filament\PanelProvider;
|
||||||
@@ -32,26 +33,24 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
'primary' => Color::Amber,
|
'primary' => Color::Amber,
|
||||||
])
|
])
|
||||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
|
||||||
->pages([
|
->pages([
|
||||||
Pages\Dashboard::class,
|
Pages\Dashboard::class,
|
||||||
ReporteVentas::class, // <--- registra aquí
|
GestionDashboard::class,
|
||||||
|
GestionStockPage::class,
|
||||||
|
PuntoVenta::class,
|
||||||
|
SettingPage::class,
|
||||||
|
ReporteVentas::class,
|
||||||
])
|
])
|
||||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
|
||||||
->widgets([
|
->widgets([
|
||||||
Widgets\AccountWidget::class,
|
Widgets\AccountWidget::class,
|
||||||
// Widgets\FilamentInfoWidget::class,
|
|
||||||
])
|
])
|
||||||
->middleware([
|
->middleware([
|
||||||
EncryptCookies::class,
|
EncryptCookies::class,
|
||||||
AddQueuedCookiesToResponse::class,
|
AddQueuedCookiesToResponse::class,
|
||||||
StartSession::class,
|
StartSession::class,
|
||||||
AuthenticateSession::class,
|
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
SubstituteBindings::class,
|
SubstituteBindings::class,
|
||||||
DisableBladeIconComponents::class,
|
|
||||||
DispatchServingFilamentEvent::class,
|
|
||||||
])
|
])
|
||||||
->authMiddleware([
|
->authMiddleware([
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware) {
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
//
|
$middleware->trustProxies(at: '*');
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions) {
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$host = getenv('DB_HOST') ?: 'localhost';
|
||||||
|
$port = getenv('DB_PORT') ?: '5432';
|
||||||
|
$dbname = getenv('DB_DATABASE') ?: 'usite_heidivers';
|
||||||
|
$user = getenv('DB_USERNAME') ?: 'usite_heidivers';
|
||||||
|
$pass = getenv('DB_PASSWORD') ?: '';
|
||||||
|
|
||||||
|
$dsn = "pgsql:host=$host;port=$port;dbname=$dbname";
|
||||||
|
try {
|
||||||
|
$pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite(STDERR, "DB not available: {$e->getMessage()}\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables = $pdo->query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
if (!in_array('sessions', $tables)) {
|
||||||
|
$pdo->exec("CREATE TABLE sessions (
|
||||||
|
id VARCHAR(255) PRIMARY KEY,
|
||||||
|
user_id BIGINT NULL,
|
||||||
|
ip_address VARCHAR(45) NULL,
|
||||||
|
user_agent TEXT NULL,
|
||||||
|
payload TEXT NOT NULL,
|
||||||
|
last_activity INTEGER NOT NULL
|
||||||
|
)");
|
||||||
|
$pdo->exec("CREATE INDEX sessions_user_id_index ON sessions (user_id)");
|
||||||
|
$pdo->exec("CREATE INDEX sessions_last_activity_index ON sessions (last_activity)");
|
||||||
|
echo "Created sessions table\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('cache', $tables)) {
|
||||||
|
$pdo->exec("CREATE TABLE cache (
|
||||||
|
key VARCHAR(255) PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
expiration INTEGER NOT NULL
|
||||||
|
)");
|
||||||
|
echo "Created cache table\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('cache_locks', $tables)) {
|
||||||
|
$pdo->exec("CREATE TABLE cache_locks (
|
||||||
|
key VARCHAR(255) PRIMARY KEY,
|
||||||
|
owner VARCHAR(255) NOT NULL,
|
||||||
|
expiration INTEGER NOT NULL
|
||||||
|
)");
|
||||||
|
echo "Created cache_locks table\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Tables check complete\n";
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Ensure storage directories exist (for volume mounts)
|
||||||
|
mkdir -p storage/framework/views \
|
||||||
|
storage/framework/cache \
|
||||||
|
storage/framework/sessions \
|
||||||
|
storage/logs \
|
||||||
|
storage/app/public
|
||||||
|
|
||||||
|
# Recreate symlink (lost on empty volume)
|
||||||
|
if [ ! -L public/storage ]; then
|
||||||
|
ln -sf ../storage/app/public public/storage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure writable
|
||||||
|
chmod -R 775 storage bootstrap/cache
|
||||||
|
chown -R www-data:www-data storage bootstrap/cache
|
||||||
|
|
||||||
|
# Create missing DB tables (sessions, cache) without breaking existing data
|
||||||
|
php /app/docker/ensure-tables.php 2>/dev/null || true
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
+12
-4
@@ -1,3 +1,6 @@
|
|||||||
|
error_log /dev/stderr warn;
|
||||||
|
access_log /dev/stdout;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
@@ -16,18 +19,23 @@ server {
|
|||||||
|
|
||||||
error_page 404 /index.php;
|
error_page 404 /index.php;
|
||||||
|
|
||||||
|
location = /ping {
|
||||||
|
return 200 "pong\n";
|
||||||
|
add_header Content-Type text/plain;
|
||||||
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass 127.0.0.1:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
fastcgi_param APP_ENV production;
|
||||||
|
fastcgi_param HTTPS on;
|
||||||
|
fastcgi_read_timeout 300s;
|
||||||
|
fastcgi_send_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ /\.(?!well-known).* {
|
location ~ /\.(?!well-known).* {
|
||||||
deny all;
|
deny all;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.css\.map$ {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
[www]
|
|
||||||
user = www-data
|
|
||||||
group = www-data
|
|
||||||
listen = 127.0.0.1:9000
|
|
||||||
listen.owner = www-data
|
|
||||||
listen.group = www-data
|
|
||||||
listen.mode = 0660
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 10
|
|
||||||
pm.start_servers = 2
|
|
||||||
pm.min_spare_servers = 1
|
|
||||||
pm.max_spare_servers = 3
|
|
||||||
pm.max_requests = 500
|
|
||||||
clear_env = no
|
|
||||||
catch_workers_output = yes
|
|
||||||
php_admin_flag[display_errors] = off
|
|
||||||
php_admin_flag[log_errors] = on
|
|
||||||
php_admin_value[error_log] = /proc/self/fd/2
|
|
||||||
Reference in New Issue
Block a user