3.4 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Docker base image for Laravel applications using FrankenPHP, designed to be lightweight and production-ready. The repository contains minimal configuration files to create a containerized Laravel runtime environment.
Architecture
- Base Image: Uses
dunglas/frankenphp
as the foundation - Server: FrankenPHP with Laravel Octane integration
- Database: Configured for SQLite by default (with support for PostgreSQL and MySQL extensions)
- Application: Expects Laravel application code to be mounted at
/app
Key Files
Dockerfile
: Main container configuration with PHP extensions and entrypoint setupentrypoint.sh
: Container startup script that handles Laravel initialization.env.docker
: Production environment configuration for containerized Laravel apps.github/workflows/build.yml
: CI/CD pipeline for building and pushing to Docker registry
Docker Commands
Building the Image
docker build -t laravel-base .
Running a Container
# Assumes Laravel application code is mounted to /app
docker run -p 8000:8000 -v /path/to/laravel/app:/app laravel-base
Container Behavior
The entrypoint script (entrypoint.sh
) automatically:
- Runs database migrations (
php artisan migrate --force
) - Creates storage symlink (
php artisan storage:link
) - Generates APP_KEY if not set in environment
- Clears and caches configuration and views
- Executes custom hook script if
/app/hook.sh
exists - Starts supervisor services (queue worker and/or scheduler) if enabled via environment variables
- Starts FrankenPHP server on port 8000 with admin port 2019
Hook System
Applications extending this base image can provide a hook.sh
script at /app/hook.sh
to run custom initialization commands. The hook script is executed after Laravel setup but before the server starts.
Example Usage in Extending Dockerfile
FROM gitgud.foo/thegrind/laravel-base:latest
COPY ./hook.sh /app/hook.sh
# Your application code and additional setup
Example hook.sh
#!/bin/sh
# Custom application initialization
php /app/artisan db:seed --force
php /app/artisan queue:restart
Queue Workers and Scheduler
The base image includes supervisor configuration for Laravel queue workers and scheduler. These can be optionally enabled by extending images using environment variables:
ENABLE_QUEUE_WORKER=true
- Starts Laravel queue worker processENABLE_SCHEDULER=true
- Starts Laravel scheduler process
Supervisor Configuration Files
supervisord.conf
- Main supervisor configurationlaravel-queue.conf
- Queue worker process configurationlaravel-scheduler.conf
- Scheduler process configuration
Usage Example
FROM gitgud.foo/thegrind/laravel-base:latest
ENV ENABLE_QUEUE_WORKER=true
ENV ENABLE_SCHEDULER=true
# Your application setup...
Environment Configuration
The .env.docker
file is copied into the container and includes:
- SQLite database configuration
- FrankenPHP/Octane server settings
- Production-oriented cache and session settings
- Application name: "FlowTODO"
Deployment
GitHub Actions workflow triggers on release publication and pushes to gitgud.foo/thegrind/laravel-base
registry with both latest
and version tags.