Fix production 500 error: remove build-time config:cache and fix runtime database permissions and seeding
This commit is contained in:
+1
-1
@@ -48,5 +48,5 @@ RUN mkdir -p /app/storage /app/bootstrap/cache /app/database \
|
|||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["sh", "-c", "php artisan storage:link && php artisan migrate --force && frankenphp run --config /etc/caddy/Caddyfile"]
|
CMD ["sh", "-c", "php artisan storage:link && mkdir -p /app/database /app/storage/framework/cache /app/storage/framework/sessions /app/storage/framework/views /app/storage/logs && touch /app/database/database.sqlite && chmod -R 777 /app/database /app/storage && php artisan migrate --force && php artisan db:seed --force && frankenphp run --config /etc/caddy/Caddyfile"]
|
||||||
|
|
||||||
|
|||||||
+2
-6
@@ -10,12 +10,8 @@ cmds = [
|
|||||||
|
|
||||||
[phases.build]
|
[phases.build]
|
||||||
cmds = [
|
cmds = [
|
||||||
"npm run build",
|
"npm run build"
|
||||||
"php artisan config:cache",
|
|
||||||
"php artisan route:cache",
|
|
||||||
"php artisan view:cache"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[start]
|
[start]
|
||||||
cmd = "php artisan storage:link && touch database/database.sqlite && php artisan migrate --force && php artisan serve --host=0.0.0.0 --port=80"
|
cmd = "php artisan storage:link && mkdir -p database storage/framework/cache storage/framework/sessions storage/framework/views storage/logs && touch database/database.sqlite && chmod -R 777 database storage && php artisan migrate --force && php artisan db:seed --force && php artisan config:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache && php artisan serve --host=0.0.0.0 --port=80"
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,54 @@ use App\Http\Controllers\Admin\MakerWorldController;
|
|||||||
use App\Http\Controllers\CartController;
|
use App\Http\Controllers\CartController;
|
||||||
use App\Http\Controllers\CheckoutController;
|
use App\Http\Controllers\CheckoutController;
|
||||||
use App\Http\Controllers\ShopController;
|
use App\Http\Controllers\ShopController;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Product;
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||||
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
// Health & Diagnostics
|
||||||
|
Route::get('/health-debug', function () {
|
||||||
|
$dbPath = config('database.connections.sqlite.database');
|
||||||
|
|
||||||
|
$diagnostics = [
|
||||||
|
'php_version' => PHP_VERSION,
|
||||||
|
'app_env' => config('app.env'),
|
||||||
|
'has_app_key' => ! empty(config('app.key')),
|
||||||
|
'app_key_len' => strlen((string) config('app.key')),
|
||||||
|
'db_connection' => config('database.default'),
|
||||||
|
'db_path' => $dbPath,
|
||||||
|
'db_file_exists' => is_string($dbPath) && file_exists($dbPath),
|
||||||
|
'db_dir_writable' => is_string($dbPath) && is_writable(dirname($dbPath)),
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
DB::connection()->getPdo();
|
||||||
|
$diagnostics['db_pdo'] = 'CONNECTED';
|
||||||
|
$diagnostics['tables'] = Schema::getTableListing();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$diagnostics['db_pdo_error'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$diagnostics['categories_count'] = Category::count();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$diagnostics['categories_error'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$diagnostics['products_count'] = Product::count();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$diagnostics['products_error'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($diagnostics);
|
||||||
|
})->withoutMiddleware([
|
||||||
|
StartSession::class,
|
||||||
|
EncryptCookies::class,
|
||||||
|
]);
|
||||||
|
|
||||||
// Shop & Product routes
|
// Shop & Product routes
|
||||||
Route::get('/', [ShopController::class, 'index'])->name('home');
|
Route::get('/', [ShopController::class, 'index'])->name('home');
|
||||||
|
|||||||
Reference in New Issue
Block a user