Stu Mason
Stu Mason

Activity

Issue Resolved

Issue #16 closed: Best Practices: Laravel Log Management and Deployment Cleanup on Coolify

Background

After troubleshooting a severe disk usage issue (81% disk usage, 30GB log file from 288,630 errors over 10 months), we've identified critical best practices for Laravel apps deployed on Coolify.

๐Ÿ”„ Log Configuration for New Laravel Apps

When deploying Laravel applications on Coolify, always configure these environment variables:

LOG_STACK=daily
LOG_DAILY_MAX_FILES=7
CACHE_STORE=redis  # NOT database

Why:

  • LOG_STACK=daily creates daily log files instead of a single ever-growing file
  • LOG_DAILY_MAX_FILES=7 automatically deletes logs older than 7 days
  • CACHE_STORE=redis prevents stale database references and improves performance

๐Ÿงน Regular Maintenance

Monthly Tasks:

  • Review and remove old deployments in Coolify UI
    • Old deployment images accumulate and can consume significant disk space
    • Coolify keeps previous deployment images unless manually removed
    • Check: Applications โ†’ Deployments โ†’ Delete old deployments

What we found:

  • 85% of Docker images were unused old deployments
  • Build cache accumulated to 1.75GB
  • Old deployment images totaled 12GB+

๐Ÿ“Š Monitoring

Consider adding:

  • Automated log rotation scripts for emergency cleanup
  • Monitoring for log files exceeding size thresholds
  • Regular docker system prune schedules

Feature Requests

For Coolify Platform

  1. Default Laravel Environment Variables

    • Pre-populate LOG_STACK=daily and LOG_DAILY_MAX_FILES=7 for Laravel apps
    • Warn when CACHE_STORE=database is detected
  2. Deployment Cleanup

    • Add option to auto-delete deployments older than N days
    • Show deployment disk usage in UI
    • One-click cleanup for old deployment images
  3. Log Management

    • Built-in log rotation for application containers
    • Alert when application logs exceed size threshold
    • Log size monitoring in application metrics

References

This issue documents lessons learned from a production incident where:

  • Single laravel.log file grew to 30GB
  • Server reached 81% disk usage
  • 288,630 database connection errors logged over 10 months
  • Issue went unnoticed due to lack of application-level log monitoring

Action Items

  • Document these best practices in README/docs
  • Create deployment template with recommended settings
  • Add pre-deployment checklist
  • Consider Coolify feature requests for auto-cleanup

Impact: Following these practices can prevent critical disk space issues and improve application performance.