agentleFS
STIFLEUR390STIFLEUR390/agent-skills/skills/laravel-deploy/SKILL.md

laravel-deploy

Skill0 starsChanged 28 days agoMITView on GitHub

Déploiement et infrastructure pour Laravel 13. Docker, CI/CD, Forge, Vapor, Coolify, Nginx. Utiliser quand on déploie une app, on configure Docker, on met en place le CI/CD, ou on configure le serveur.

  • Reads credentials

The file

Files
SKILL.md

Laravel Deploy — Déploiement Laravel 13

Tu es un expert en déploiement Laravel 13. Ton rôle est de guider le déploiement sécurisé et efficace des applications Laravel.

Quand utiliser

  • Déployer une application Laravel
  • Configurer Docker
  • Mettre en place le CI/CD
  • Configurer le serveur (Nginx, Apache)
  • Optimiser pour la production

Docker

Dockerfile optimisé

# Build stage
FROM php:8.3-fpm AS builder

WORKDIR /var/www

COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts

COPY . .
RUN php artisan config:cache && \
    php artisan route:cache && \
    php artisan view:cache

# Production stage
FROM php:8.3-fpm

WORKDIR /var/www

COPY --from=builder /var/www /var/www

RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache

EXPOSE 9000

CMD ["php-fpm"]

docker-compose.yml

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/var/www
    depends_on:
      - db
      - redis
    environment:
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_DATABASE=laravel
      - DB_USERNAME=laravel
      - DB_PASSWORD=secret

  db:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: laravel
      MYSQL_USER: laravel
      MYSQL_PASSWORD: secret
    volumes:
      - db_data:/var/lib/mysql

  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - .:/var/www
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app

  redis:
    image: redis:alpine

volumes:
  db_data:

CI/CD

GitHub Actions

name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          extensions: mbstring, xml, ctype, json, bcmath, pdo, sqlite
          coverage: none

      - name: Install Dependencies
        run: composer install --no-progress --prefer-dist

      - name: Copy Environment File
        run: cp .env.testing .env

      - name: Generate App Key
        run: php artisan key:generate

      - name: Run Migrations
        run: php artisan migrate --force

      - name: Run Tests
        run: php artisan test

      - name: Run PHPStan
        run: vendor/bin/phpstan analyse

  deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'

    steps:
      - uses: actions/checkout@v4

      - name: Deploy to Production
        run: |
          # Déploiement selon la plateforme
          echo "Deploying..."

Nginx

server {
    listen 80;
    server_name example.com;
    root /var/www/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Optimisation production

# Cache everything
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache

# Optimiser l'autoloader
composer install --optimize-autoloader --no-dev

# Vérifier la config
php artisan config:clear
php artisan route:clear
php artisan view:clear

Health check

// routes/web.php
Route::get('/health', function () {
    try {
        DB::connection()->getPdo();
        Cache::get('test');
        return response('OK', 200);
    } catch (\Exception $e) {
        return response('ERROR', 500);
    }
});

Bonnes pratiques

  1. Multi-stage Docker build — Réduire la taille de l'image
  2. Variables d'env jamais dans les images — Utiliser .env ou des secrets
  3. Health checks — Pour le monitoring et le load balancer
  4. Zero-downtime deployment — Rolling updates ou blue-green
  5. Cache en production — Config, routes, views
  6. Logging structuré — Pour le debugging en production
  7. Monitoring — Pulse, Telescope, ou outils externes
  8. Backup automatique — Base de données et storage
  9. SSL/TLS — Let's Encrypt ou certificat managé
  10. Supervisor pour les workers — Queue workers en production

Validation

  • Docker build passe
  • CI/CD configuré et fonctionnel
  • Nginx configuré correctement
  • Health check répond
  • SSL configuré
  • Logs configurés
  • Backup automatique

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.