# Use an official PHP image with Apache
FROM php:7.4-apache

# Install Vim (optional)
RUN apt-get update && \
    apt-get install -y vim && \
    rm -rf /var/lib/apt/lists/*

RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/localhost.key -out /etc/ssl/certs/localhost.crt -subj "/C=US/ST=YourState/L=YourCity/O=YourOrganization/CN=localhost"
RUN htpasswd -nb davuser davuser > /var/www/.htpasswd

# Copy the custom Apache virtual host config
COPY conf/my-httpd-vhosts.conf /etc/apache2/sites-available/my-ssl.conf
COPY conf/webdav.conf /etc/apache2/sites-available/webdav.conf

# Enable SSL module, configure Apache for PHP support, and enable our SSL site configuration
RUN a2enmod ssl && \
    a2enmod rewrite && \
    a2enmod dav && \
    a2enmod dav_fs && \
    a2enmod dav_lock && \
    a2dissite 000-default default-ssl && \
    a2ensite my-ssl && \
    a2ensite webdav && \
    apachectl configtest

