FROM alpine:latest ARG ENABLE_PROXY=0 ARG ENABLE_PHP=0 ARG ENABLE_DAV=0 ARG EXTRA_PACKAGES="" ARG EXTRA_MODULES="" COPY conf/ /tmp/conf COPY docker-entrypoint.sh /docker-entrypoint.sh RUN set -ex; \ # Install packages packages="${EXTRA_PACKAGES} apache2 libxml2-dev apache2-utils apr-util-dbm_db"; \ if [ ${ENABLE_PHP} -ne 0 ]; then \ packages="$packages php7-apache2"; \ fi; \ apk update && apk upgrade && apk add --no-cache $packages; \ \ # Enable optional modules modules="${EXTRA_MODULES} authn_core authn_file authz_core authz_user auth_basic auth_digest alias headers mime setenvif"; \ if [ ${ENABLE_PROXY} -ne 0 ]; then \ modules="$modules rewrite proxy proxy_http"; \ fi; \ if [ ${ENABLE_DAV} -ne 0 ]; then \ modules="$modules dav dav_fs"; \ fi; \ for i in $modules; do \ sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" "/etc/apache2/httpd.conf"; \ done; \ \ # Create empty default DocumentRoot. mkdir -p "/var/www/html"; \ # Create directories for Dav data and lock database. mkdir -p "/var/dav/data"; \ \ # Configure Apache sed -i -e "s|Listen .*|Listen 8080|" "/etc/apache2/httpd.conf"; \ sed -i -e "s|CustomLog logs.*|CustomLog /proc/self/fd/1 combined|" "/etc/apache2/httpd.conf"; \ sed -i -e "s|ErrorLog logs.*|ErrorLog /proc/self/fd/2|" "/etc/apache2/httpd.conf"; \ sed -i -e "s|PidFile .*|PidFile /tmp/apache.pid|" "/etc/apache2/conf.d/mpm.conf"; \ \ # Include enabled configs and sites. printf '%s\n' "IncludeOptional /tmp/conf/sites-enabled/*.conf" \ >> "/etc/apache2/httpd.conf"; \ printf '%s\n' "IncludeOptional /tmp/conf/conf-enabled/*.conf" \ >> "/etc/apache2/httpd.conf"; \ \ # Enable module configuration and default site. mkdir -p "/tmp/conf/conf-enabled"; \ mkdir -p "/tmp/conf/sites-enabled"; \ ln -s ../sites-available/default.conf "/tmp/conf/sites-enabled"; \ for i in $modules; do \ if [ -f /tmp/conf/conf-available/${i}.conf ]; then \ ln -s ../conf-available/${i}.conf "/tmp/conf/conf-enabled"; \ fi; \ done; \ \ # Remove extra configs #rm /etc/apache2/conf.d/default.conf; \ rm /etc/apache2/conf.d/info.conf; \ rm /etc/apache2/conf.d/languages.conf; \ #rm /etc/apache2/conf.d/mpm.conf; \ rm /etc/apache2/conf.d/userdir.conf; \ \ # Allow scripts to alter configuration chmod -R g=u /tmp/conf; \ chmod g=u /etc/passwd VOLUME /var/dav/data VOLUME /var/www/html EXPOSE 8080/tcp 8043/tcp ENTRYPOINT [ "/docker-entrypoint.sh" ] CMD [ "httpd", "-DFOREGROUND" ]