Enable .htaccess support in Apache container
All checks were successful
WHP Default Container / Build-and-Push (push) Successful in 14s

- Modified Dockerfile to set AllowOverride All for htdocs directory
- Enabled mod_rewrite module for common .htaccess functionality
- Added CLAUDE.md with project documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-23 19:08:06 -07:00
parent da058d92dc
commit 03be2342d1
2 changed files with 62 additions and 0 deletions

56
CLAUDE.md Normal file
View File

@@ -0,0 +1,56 @@
# 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-based web server container that provides an Apache HTTP Server with an auto-detection mechanism for web content. If the web directory is empty on startup, it automatically copies a default landing page.
## Key Architecture
- **Container Base**: Apache HTTP Server on Alpine Linux (`httpd:alpine`)
- **Startup Logic**: `scripts/startup.sh` handles the auto-detection and default content copying
- **Default Content**: Professional landing page in root `index.html`
- **Web Root**: `/usr/local/apache2/htdocs` inside the container
## Common Commands
### Build and Run
```bash
# Build the container
docker build -t my-web-server .
# Run with default settings
docker run -p 80:80 my-web-server
# Run with volume mount for custom content
docker run -p 80:80 -v /path/to/web/content:/usr/local/apache2/htdocs my-web-server
# Run on custom port
docker run -p 8080:80 my-web-server
```
### Development
```bash
# View container logs
docker logs <container-id>
# Execute shell in running container
docker exec -it <container-id> /bin/sh
# Test startup script locally
chmod +x scripts/startup.sh
./scripts/startup.sh
```
## Server Deployment
- The git directory on the servers are /root/whp and once you do a git pull, to sync web files you would run the rsync command for web-files/ to /docker/whp/web/
## Important Implementation Details
1. **Auto-Detection Logic**: The startup script checks if `/usr/local/apache2/htdocs` is empty (ignoring hidden files) before copying default content
2. **Non-Destructive**: Only copies default content if the directory is truly empty - won't overwrite existing files
3. **Startup Flow**:
- Container starts → `startup.sh` runs → Checks for content → Copies if empty → Starts Apache
4. **Default Landing Page**: Responsive, professional design with proper meta tags and CSS

View File

@@ -1,5 +1,11 @@
FROM httpd:alpine
# Enable .htaccess files by modifying Apache configuration
RUN sed -i '/<Directory "\/usr\/local\/apache2\/htdocs">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /usr/local/apache2/conf/httpd.conf
# Enable mod_rewrite module (commonly used in .htaccess)
RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /usr/local/apache2/conf/httpd.conf
# Copy the default landing page to the container
COPY index.html /index.html
RUN rm -f /usr/local/apache2/htdocs/index.html