From 2d8efa1787ffa56dfc78edb62f4dbc94c1c9450e Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 21 Aug 2019 03:19:29 +0200 Subject: Change to system-wide Apache installation --- 2.4/Dockerfile | 85 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) (limited to '2.4/Dockerfile') diff --git a/2.4/Dockerfile b/2.4/Dockerfile index 4645a3f..26757fc 100644 --- a/2.4/Dockerfile +++ b/2.4/Dockerfile @@ -1,4 +1,4 @@ -FROM httpd:alpine +FROM alpine:latest ARG ENABLE_PROXY=0 ARG ENABLE_PHP=0 @@ -7,30 +7,18 @@ ARG ENABLE_DAV=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 +COPY conf/ /tmp/conf +COPY docker-entrypoint.sh /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"; \ + # 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 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"; \ + apk update && apk upgrade && apk add --no-cache $packages; \ \ - # 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. + # 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"; \ @@ -38,36 +26,49 @@ RUN set -ex; \ if [ ${ENABLE_DAV} -ne 0 ]; then \ modules="$modules dav dav_fs"; \ fi; \ - if [ ${ENABLE_PHP} -ne 0 ]; then \ - modules="$modules php7"; \ - fi; \ for i in $modules; do \ - sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" "conf/httpd.conf"; \ + 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 port + sed -i -e "s|Listen .*|Listen 8080|" "/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' "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. + 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"; \ \ - have_conf=0; \ - mkdir -p "conf/conf-enabled"; \ - mkdir -p "conf/sites-enabled"; \ + # 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 conf/conf-available/${i}.conf ]; then \ - have_conf=1; \ - ln -s ../conf-available/${i}.conf "conf/conf-enabled"; \ + if [ -f /etc/apache2/conf-available/${i}.conf ]; then \ + ln -s ../conf-available/${i}.conf "/tmp/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 + \ + # 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-foreground" ] +ENTRYPOINT [ "/docker-entrypoint.sh" ] +CMD [ "httpd", "-DFOREGROUND" ] -- cgit v1.2.3