Review follow-up (PR #61 review 121): - create-vhost.sh ignores DOCROOT_SUBDIR (log line) unless environment=DEV, and entrypoint.sh only creates the folder in DEV. Defence in depth so a production container cannot move its web root through the env, even if a site owner got the variable into the container (WHP also denies it now). - dev-mode.sh: XDEBUG_START defaults to trigger instead of yes, so CLI runs (wp-cli) do not print "Could not connect to debugging client" without an IDE. XDEBUG_START=yes still connects on every request. - README/CLAUDE.md updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
3.4 KiB
3.4 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Cloud Apache Container (CAC) is a Docker-based PHP web hosting environment that supports multiple PHP versions (7.4 through 8.6) with Apache, designed for both local development and production deployment.
Common Development Commands
Local Development Setup
# Quick start with automated setup (creates helper scripts)
./local-dev.sh -n local-dev
# With specific PHP version
./local-dev.sh -n myproject -a 84 # PHP 8.4
# Helper scripts created by local-dev.sh:
./instance_start # Start container
./instance_stop # Stop container
./instance_logs # Tail Apache logs
./instance_db_info # Show MySQL credentials
Building and Testing
# Build container locally
docker build -t cac:latest .
# Build with specific PHP version
docker build --build-arg PHPVER=83 -t cac:php83 .
# Run container manually
docker run -d -p 80:80 -p 443:443 \
-e environment=DEV \
-e uid=$(id -u) -e user=$(whoami) -e domain=localhost \
-v"$(pwd)/user":/home/$(whoami) \
--name test-container cac:php83
Server Deployment
- Production git directory:
/root/whp - After
git pull, sync web files:rsync -av web-files/ /docker/whp/web/
Architecture and Key Components
Directory Structure
/scripts/- Container setup scripts (entrypoint, PHP installers, vhost creation)/config/- Apache and PHP configuration files/web-files/- Default web content (ping endpoint)/.gitea/workflows/- CI/CD pipeline for multi-PHP version builds
Container Behavior
-
Entrypoint Flow (
scripts/entrypoint.sh):- Creates user with specified UID
- Sets up directory structure
- Configures Apache vhost based on environment variables
- In DEV mode: starts MariaDB and Memcached
- Starts Apache and PHP-FPM
-
Environment Modes:
- DEV (
environment=DEV): Local database, memcached, automatic backups - PROD (default): Expects external database/cache services
- DEV (
-
PHP Version Management:
- Fixed by the IMAGE TAG (
cac:php83, ...;cac:latest= PHP 8.5). ThePHPVERenv var does not switch versions; DEV mode warns if it disagrees with the image - Each version has dedicated install script in
/scripts/ - PHP-FPM configuration dynamically created based on version
- Fixed by the IMAGE TAG (
Key Environment Variables
uid(required): User ID for file permissionsuser(required): Username for container userdomain(required): Primary domain for Apache vhostserveralias: Additional domains (comma-separated)PHPVER: informational only (the image tag selects PHP)DOCROOT_SUBDIR: servepublic_html/<subdir>(Laravel/CI4public); validated like WHP's docrootsub; default empty = unchanged; honoured only whenenvironment=DEV(ignored with a log line otherwise, so a production site cannot move its web root through it)XDEBUG=1,PUBLIC_HTTPS_PORT: DEV mode onlyenvironment: DEV or PROD mode
Important Technical Details
- Health Check: Available at
/pingendpoint - Logs Location:
/home/$user/logs/apache/and/home/$user/logs/php-fpm/ - Database Backups (DEV mode): Every 15 minutes to
/home/$user/_db_backups/ - Log Rotation: Compress after 3 days, delete after 7 days
- SSL: Self-signed certificate auto-generated, proper SSL configured
- WordPress: WP-CLI pre-installed for WordPress development