diff --git a/.gitea/workflows/build-push.yaml b/.gitea/workflows/build-push.yaml new file mode 100644 index 0000000..87965ac --- /dev/null +++ b/.gitea/workflows/build-push.yaml @@ -0,0 +1,34 @@ +name: WHP Default Container +run-name: ${{ gitea.actor }} pushed a change to main +on: + push: + branches: + - main + +jobs: + Build-and-Push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v3 + + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: repo.anhonesthost.net + username: ${{ secrets.CI_USER }} + password: ${{ secrets.CI_TOKEN }} + + - name: Build Image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64 + push: true + tags: | + repo.anhonesthost.net/cloud-hosting-platform/whp-default:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2fe3ca2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM httpd:alpine + +# Copy the default landing page to the container +COPY index.html /index.html + +# Copy the startup script +COPY scripts/startup.sh /startup.sh + +# Make the startup script executable +RUN chmod +x /startup.sh + +# Set the startup script as the entrypoint +ENTRYPOINT ["/startup.sh"] + diff --git a/README.md b/README.md index e69de29..e5674e2 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,93 @@ +# 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` diff --git a/index.html b/index.html new file mode 100644 index 0000000..c986ba9 --- /dev/null +++ b/index.html @@ -0,0 +1,409 @@ + + + + + + Welcome to Your Domain - Web Hosting + + + +
+
+

Your Domain is Live! 🎉

+

Congratulations! Your web hosting is now active and ready to serve your website.

+ +
+

⚠️ This is a Default Landing Page

+

This container is currently configured to serve static assets only. To configure your actual website, please use the Web Hosting Panel.

+
+ + Get Started with Your Website +
+
+ +
+
+

Current Status

+

Your web hosting environment is operational

+ +
+

📋 Current Configuration

+

This container is running in static-only mode. You can upload HTML, CSS, JavaScript, and image files, but dynamic features like PHP, databases, and server-side processing are not available in this configuration.

+
+ +
+
+
+

Web Server

+

Apache web server is running and serving static content

+
+ +
+
+

Domain DNS

+

Your domain is properly configured and pointing to this server

+
+ +
+
+

SSL Certificate

+

Secure HTTPS connection is available for your domain

+
+ +
+
+

Static Assets

+

Ready to serve HTML, CSS, JavaScript, and image files

+
+
+
+
+ +
+
+

What You Can Do Now

+

Options for getting your website up and running

+ +
+
+
📁
+

Upload Static Files

+

Upload your HTML, CSS, JavaScript, and image files directly to this container for a simple static website.

+
+ +
+
⚙️
+

Configure Full Hosting

+

Use the Web Hosting Panel to configure dynamic hosting with PHP, databases, and server-side processing.

+
+ +
+
🚀
+

WordPress Installation

+

Use our easy WordPress install tool to quickly set up a professional website with a content management system.

+
+ +
+
🛠️
+

Custom Applications

+

Install other popular applications like Joomla, Drupal, or custom PHP applications through the control panel.

+
+ +
+
📊
+

Database Setup

+

Configure MySQL or PostgreSQL databases for dynamic content and applications.

+
+ +
+
📧
+

Email Configuration

+

Set up professional email addresses for your domain through the hosting panel.

+
+
+
+
+ +
+
+

Next Steps

+

How to configure your website through the Web Hosting Panel

+ +
+
+ 1 + Log into Web Hosting Panel - Access your hosting control panel to manage your domain and hosting configuration. +
+ +
+ 2 + Select Your Site - Navigate to the "Sites" section and select this domain to configure its hosting settings. +
+ +
+ 3 + Choose Your Software - Configure the software stack you want to use (PHP, databases, etc.) or use our one-click installers. +
+ +
+ 4 + Install Applications - Use our easy WordPress install tool or install other applications like Joomla, Drupal, or custom PHP apps. +
+ +
+ 5 + Upload Your Files - Upload your website files and configure your databases through the file manager and database tools. +
+ +
+ 6 + Configure Email - Set up professional email addresses for your domain (yourname@yourdomain.com). +
+
+
+
+ + + + diff --git a/scripts/startup.sh b/scripts/startup.sh new file mode 100755 index 0000000..44099dd --- /dev/null +++ b/scripts/startup.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# Default web directory for Apache +WEB_DIR="/usr/local/apache2/htdocs" + +echo "Starting web server initialization..." + +# Check if web directory exists, create if it doesn't +if [ ! -d "$WEB_DIR" ]; then + echo "Creating web directory: $WEB_DIR" + mkdir -p "$WEB_DIR" +fi + +# Check if web directory is empty (no files or only hidden files) +if [ -z "$(ls -A "$WEB_DIR" 2>/dev/null | grep -v '^\.')" ]; then + echo "Web directory is empty. Copying default landing page..." + cp /index.html "$WEB_DIR/" + echo "Default landing page copied successfully." +else + echo "Web directory contains files. Skipping default page copy." +fi + +echo "Starting Apache web server..." +echo "Server will be available at: http://localhost:80" + +# Start Apache in foreground +exec httpd-foreground \ No newline at end of file