my-homelab-configs/apps/website/Dockerfile

37 lines
1.1 KiB
Docker

FROM alpine:3.19
# Install Apache, PHP 8.2, and the SQLite extensions
RUN apk update && apk add --no-cache \
apache2 \
php82 \
php82-apache2 \
php82-pdo \
php82-pdo_sqlite \
php82-curl \
curl \
shadow
# Symlink php82 to php so scripts run naturally if needed
RUN ln -sf /usr/bin/php82 /usr/bin/php
# Alpine keeps Apache site configs here instead of a2enmod
RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /etc/apache2/httpd.conf && \
sed -i 's/#LoadModule headers_module/LoadModule headers_module/' /etc/apache2/httpd.conf
# Copy files directly into Alpine's default web root
COPY . /var/www/localhost/htdocs/
# Set up the database directory permissions
RUN mkdir -p /var/www/localhost/htdocs/db && \
chown -R apache:apache /var/www/localhost/htdocs/db && \
chmod -R 755 /var/www/localhost/htdocs/db
# Match local user permissions for the runtime user (Alpine uses 'apache' instead of 'www-data')
RUN usermod -u 1000 apache && \
groupmod -g 1000 apache
EXPOSE 80
# Start Apache in the foreground
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]