# Dockerfile (apache-static)
FROM httpd:2.4

LABEL maintainer="random@gmail.com"

# Enable required Apache modules for user directories and PHP
RUN sed -i \
    -e 's/#LoadModule userdir_module/LoadModule userdir_module/' \
    -e 's/#LoadModule vhost_alias_module/LoadModule vhost_alias_module/' \
    -e 's/#LoadModule rewrite_module/LoadModule rewrite_module/' \
    -e 's/#Include conf\/extra\/httpd-userdir.conf/Include conf\/extra\/httpd-userdir.conf/' \
    /usr/local/apache2/conf/httpd.conf

# Add custom configuration for user directories
COPY httpd-userdir.conf /usr/local/apache2/conf/extra/httpd-userdir.conf

# Create example student org directories with basic content
RUN mkdir -p /home/studentorg1/public_html && \
    echo "<h1>Welcome to Student Org 1's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg1/public_html/index.html && \
    mkdir -p /home/studentorg2/public_html && \
    echo "<h1>Welcome to Student Org 2's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg2/public_html/index.html && \
    mkdir -p /home/studentorg3/public_html && \
    echo "<h1>Welcome to Student Org 3's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg3/public_html/index.html

# Set proper ownership
RUN chown -R www-data:www-data /home

EXPOSE 80
