# Web Server Container with Auto-Landing Page This Docker container provides a web server that automatically checks for content in the web directory and provides a beautiful default landing page if none exists. ## Features - **Auto-Detection**: Checks if the web directory (`/usr/local/apache2/htdocs`) is empty on startup - **Default Landing Page**: Automatically copies a modern, responsive landing page if no content exists - **Non-Destructive**: Only copies the default page if the directory is truly empty - **Apache Web Server**: Based on the official `httpd:alpine` image for lightweight performance ## How It Works 1. **Startup Check**: When the container starts, it runs a startup script that: - Checks if the web directory exists (creates it if needed) - Determines if the directory is empty (ignoring hidden files) - Copies the default `index.html` if no content is found 2. **Web Server**: After the check, Apache starts normally and serves content from the web directory 3. **Persistence**: If you mount a volume with existing content, the default page won't be copied ## Usage ### Basic Usage ```bash # Build the container docker build -t my-web-server . # Run the container docker run -p 80:80 my-web-server ``` ### With Volume Mount (for persistent content) ```bash # Mount a local directory to preserve your content docker run -p 80:80 -v /path/to/your/web/content:/usr/local/apache2/htdocs my-web-server ``` ### With Custom Port ```bash # Run on a different port docker run -p 8080:80 my-web-server ``` ## File Structure ``` . ├── Dockerfile # Container definition ├── index.html # Default landing page (beautiful, responsive) ├── scripts/ │ └── startup.sh # Startup script that handles the logic └── README.md # This file ``` ## Customization ### Modifying the Default Landing Page Edit the `index.html` file before building the container. The page includes: - Modern gradient background - Responsive design - Feature cards - Smooth animations - Mobile-friendly layout ### Modifying the Startup Logic Edit `scripts/startup.sh` to change: - Web directory path - File detection logic - Additional initialization steps ## Container Details - **Base Image**: `httpd:alpine` (lightweight Apache server) - **Web Directory**: `/usr/local/apache2/htdocs` - **Default Port**: 80 - **Entrypoint**: `/startup.sh` ## Troubleshooting ### Container Won't Start - Check that `scripts/startup.sh` is executable: `chmod +x scripts/startup.sh` - Verify the Dockerfile syntax: `docker build -t test .` ### Default Page Not Appearing - Check container logs: `docker logs ` - Verify the web directory is actually empty - Ensure no volume is mounted that contains files ### Permission Issues - The container runs as the default Apache user - If mounting volumes, ensure proper permissions: `chmod 755 /path/to/web/content`