FROM httpd:alpine ARG ENABLE_PROXY=0 ARG ENABLE_DAV=0 ARG ENABLE_PHP5=0 ARG EXTRA_PACKAGES="" ARG EXTRA_MODULES="" # These variables are inherited from the httpd:alpine image: # ENV HTTPD_PREFIX /usr/local/apache2 # WORKDIR "$HTTPD_PREFIX" COPY conf/ conf/ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN set -ex; \ # Install openssl if we need to generate a self-signed certificate. packages="${EXTRA_PACKAGES} openssl apr-util-dbm_db"; \ if [ ${ENABLE_PHP5} -ne 0 ]; then \ packages="$packages php5-apache2"; \ fi; \ apk add --no-cache $packages; \ # Create empty default DocumentRoot. mkdir -p "/var/www/html"; \ # Create directories for Dav data and lock database. mkdir -p "/var/lib/dav/data"; \ \ # Configure port sed -i -e "s|Listen .*|Listen 8080|" "conf/httpd.conf"; \ # Configure file paths sed -i -e "s|PidFile .*|PidFile /tmp/apache.pid|" "conf/extra/httpd-mpm.conf"; \ # Make sure authentication modules are enabled. 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; \ if [ ${ENABLE_PHP5} -ne 0 ]; then \ modules="$modules php5"; \ fi; \ for i in $modules; do \ sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" "conf/httpd.conf"; \ done; \ \ # Include enabled configs and sites. printf '%s\n' "PidFile /tmp/httpd.pid" \ >> "conf/httpd.conf"; \ printf '%s\n' "Include conf/sites-enabled/*.conf" \ >> "conf/httpd.conf"; \ printf '%s\n' "Include conf/conf-enabled/*.conf" \ >> "conf/httpd.conf"; \ # Enable module configuration and default site. \ have_conf=0; \ mkdir -p "conf/conf-enabled"; \ mkdir -p "conf/sites-enabled"; \ for i in $modules; do \ if [ -f conf/conf-available/${i}.conf ]; then \ have_conf=1; \ ln -s ../conf-available/${i}.conf "conf/conf-enabled"; \ fi; \ done; \ ln -s ../sites-available/default.conf "conf/sites-enabled"; \ if [ $have_conf -eq 0 ]; then \ touch conf/conf-enabled/dummy.conf ;\ fi EXPOSE 8080/tcp 8043/tcp ENTRYPOINT [ "docker-entrypoint.sh" ] CMD [ "httpd-foreground" ]