chore(docs): remove AGENTS.md file; enhance CLAUDE.md with detailed form authorization patterns and service configuration examples
This commit is contained in:
@@ -414,6 +414,27 @@ test('application form respects member permissions', function () {
|
|||||||
<x-forms.button canGate="update" :canResource="$application" type="submit">Save</x-forms.button>
|
<x-forms.button canGate="update" :canResource="$application" type="submit">Save</x-forms.button>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Service Configuration Forms
|
||||||
|
```html
|
||||||
|
<!-- Service stack configuration with authorization -->
|
||||||
|
<x-forms.input canGate="update" :canResource="$service" id="service.name" label="Service Name" />
|
||||||
|
<x-forms.input canGate="update" :canResource="$service" id="service.description" label="Description" />
|
||||||
|
<x-forms.checkbox canGate="update" :canResource="$service" instantSave id="service.connect_to_docker_network" label="Connect To Predefined Network" />
|
||||||
|
<x-forms.button canGate="update" :canResource="$service" type="submit">Save</x-forms.button>
|
||||||
|
|
||||||
|
<!-- Service-specific fields -->
|
||||||
|
<x-forms.input canGate="update" :canResource="$service" type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"
|
||||||
|
required="{{ str(data_get($field, 'rules'))?->contains('required') }}"
|
||||||
|
id="fields.{{ $serviceName }}.value"></x-forms.input>
|
||||||
|
|
||||||
|
<!-- Service restart modal - wrapped with @can -->
|
||||||
|
@can('update', $service)
|
||||||
|
<x-modal-confirmation title="Confirm Service Application Restart?"
|
||||||
|
buttonTitle="Restart"
|
||||||
|
submitAction="restartApplication({{ $application->id }})" />
|
||||||
|
@endcan
|
||||||
|
```
|
||||||
|
|
||||||
### Server Management Forms
|
### Server Management Forms
|
||||||
```html
|
```html
|
||||||
<!-- Server configuration with appropriate gates -->
|
<!-- Server configuration with appropriate gates -->
|
||||||
|
93
AGENTS.md
93
AGENTS.md
@@ -1,93 +0,0 @@
|
|||||||
# AGENTS.md
|
|
||||||
|
|
||||||
This file provides guidance to OpenCode when working with code in this repository.
|
|
||||||
|
|
||||||
## Project Overview
|
|
||||||
|
|
||||||
Coolify is an open-source, self-hostable platform for deploying applications and managing servers - an alternative to Heroku/Netlify/Vercel. It's built with Laravel (PHP) and uses Docker for containerization.
|
|
||||||
|
|
||||||
## Development Commands
|
|
||||||
|
|
||||||
### Frontend Development
|
|
||||||
- `npm run dev` - Start Vite development server for frontend assets
|
|
||||||
- `npm run build` - Build frontend assets for production
|
|
||||||
|
|
||||||
### Backend Development
|
|
||||||
Only run artisan commands inside "coolify" container when in development.
|
|
||||||
- `php artisan serve` - Start Laravel development server
|
|
||||||
- `php artisan migrate` - Run database migrations
|
|
||||||
- `php artisan queue:work` - Start queue worker for background jobs
|
|
||||||
- `php artisan horizon` - Start Laravel Horizon for queue monitoring
|
|
||||||
- `php artisan tinker` - Start interactive PHP REPL
|
|
||||||
|
|
||||||
### Code Quality
|
|
||||||
- `./vendor/bin/pint` - Run Laravel Pint for code formatting
|
|
||||||
- `./vendor/bin/phpstan` - Run PHPStan for static analysis
|
|
||||||
- `./vendor/bin/pest` - Run Pest tests
|
|
||||||
|
|
||||||
## Architecture Overview
|
|
||||||
|
|
||||||
### Technology Stack
|
|
||||||
- **Backend**: Laravel 12 (PHP 8.4)
|
|
||||||
- **Frontend**: Livewire + Alpine.js + Tailwind CSS
|
|
||||||
- **Database**: PostgreSQL 15
|
|
||||||
- **Cache/Queue**: Redis 7
|
|
||||||
- **Real-time**: Soketi (WebSocket server)
|
|
||||||
- **Containerization**: Docker & Docker Compose
|
|
||||||
|
|
||||||
### Key Components
|
|
||||||
|
|
||||||
#### Core Models
|
|
||||||
- `Application` - Deployed applications with Git integration
|
|
||||||
- `Server` - Remote servers managed by Coolify
|
|
||||||
- `Service` - Docker Compose services
|
|
||||||
- `Database` - Standalone database instances (PostgreSQL, MySQL, MongoDB, Redis, etc.)
|
|
||||||
- `Team` - Multi-tenancy support
|
|
||||||
- `Project` - Grouping of environments and resources
|
|
||||||
|
|
||||||
#### Job System
|
|
||||||
- Uses Laravel Horizon for queue management
|
|
||||||
- Key jobs: `ApplicationDeploymentJob`, `ServerCheckJob`, `DatabaseBackupJob`
|
|
||||||
- `ServerManagerJob` and `ServerConnectionCheckJob` handle job scheduling
|
|
||||||
|
|
||||||
#### Deployment Flow
|
|
||||||
1. Git webhook triggers deployment
|
|
||||||
2. `ApplicationDeploymentJob` handles build and deployment
|
|
||||||
3. Docker containers are managed on target servers
|
|
||||||
4. Proxy configuration (Nginx/Traefik) is updated
|
|
||||||
|
|
||||||
#### Server Management
|
|
||||||
- SSH-based server communication via `ExecuteRemoteCommand` trait
|
|
||||||
- Docker installation and management
|
|
||||||
- Proxy configuration generation
|
|
||||||
- Resource monitoring and cleanup
|
|
||||||
|
|
||||||
### Directory Structure
|
|
||||||
- `app/Actions/` - Domain-specific actions (Application, Database, Server, etc.)
|
|
||||||
- `app/Jobs/` - Background queue jobs
|
|
||||||
- `app/Livewire/` - Frontend components (full-stack with Livewire)
|
|
||||||
- `app/Models/` - Eloquent models
|
|
||||||
- `bootstrap/helpers/` - Helper functions for various domains
|
|
||||||
- `database/migrations/` - Database schema evolution
|
|
||||||
|
|
||||||
## Development Guidelines
|
|
||||||
|
|
||||||
### Code Organization
|
|
||||||
- Use Actions pattern for complex business logic
|
|
||||||
- Livewire components handle UI and user interactions
|
|
||||||
- Jobs handle asynchronous operations
|
|
||||||
- Traits provide shared functionality (e.g., `ExecuteRemoteCommand`)
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
- Uses Pest for testing framework
|
|
||||||
- Tests located in `tests/` directory
|
|
||||||
|
|
||||||
### Deployment and Docker
|
|
||||||
- Applications are deployed using Docker containers
|
|
||||||
- Configuration generated dynamically based on application settings
|
|
||||||
- Supports multiple deployment targets and proxy configurations
|
|
||||||
|
|
||||||
## Cloud instance
|
|
||||||
We have a cloud instance of Coolify, a hosted Coolify.
|
|
||||||
This consists of 2 horizon worker servers.
|
|
||||||
It has thousands of servers connected, thousands of users, so make sure develop features to that usecase.
|
|
43
CLAUDE.md
43
CLAUDE.md
@@ -86,6 +86,49 @@ Coolify uses a **server-side first** approach with minimal JavaScript:
|
|||||||
- **Enhanced Form Components** with built-in authorization system
|
- **Enhanced Form Components** with built-in authorization system
|
||||||
- Real-time updates via WebSocket without page refreshes
|
- Real-time updates via WebSocket without page refreshes
|
||||||
|
|
||||||
|
### Form Authorization Pattern
|
||||||
|
**IMPORTANT**: When creating or editing forms, ALWAYS include authorization:
|
||||||
|
|
||||||
|
#### For Form Components (Input, Select, Textarea, Checkbox, Button):
|
||||||
|
Use `canGate` and `canResource` attributes for automatic authorization:
|
||||||
|
```html
|
||||||
|
<x-forms.input canGate="update" :canResource="$resource" id="name" label="Name" />
|
||||||
|
<x-forms.select canGate="update" :canResource="$resource" id="type" label="Type">...</x-forms.select>
|
||||||
|
<x-forms.checkbox instantSave canGate="update" :canResource="$resource" id="enabled" label="Enabled" />
|
||||||
|
<x-forms.button canGate="update" :canResource="$resource" type="submit">Save</x-forms.button>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### For Modal Components:
|
||||||
|
Wrap with `@can` directives:
|
||||||
|
```html
|
||||||
|
@can('update', $resource)
|
||||||
|
<x-modal-confirmation title="Confirm Action?" buttonTitle="Confirm">...</x-modal-confirmation>
|
||||||
|
<x-modal-input buttonTitle="Edit" title="Edit Settings">...</x-modal-input>
|
||||||
|
@endcan
|
||||||
|
```
|
||||||
|
|
||||||
|
#### In Livewire Components:
|
||||||
|
Always add the `AuthorizesRequests` trait and check permissions:
|
||||||
|
```php
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
|
||||||
|
class MyComponent extends Component
|
||||||
|
{
|
||||||
|
use AuthorizesRequests;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->authorize('view', $this->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$this->authorize('update', $this->resource);
|
||||||
|
// ... update logic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Livewire Component Structure
|
### Livewire Component Structure
|
||||||
- Components located in `app/Livewire/`
|
- Components located in `app/Livewire/`
|
||||||
- Views in `resources/views/livewire/`
|
- Views in `resources/views/livewire/`
|
||||||
|
Reference in New Issue
Block a user