diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-08-16 06:06:49 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-08-16 06:06:49 +0200 |
commit | 33945303367244830fdd8d67d9987ad3721049ca (patch) | |
tree | 6e7efced6ba2b0a903149111dcafbeca866189ba /2.4/Dockerfile | |
parent | d0e40d97a52a599dbb110fa23ef510ca238049c5 (diff) | |
download | apache-33945303367244830fdd8d67d9987ad3721049ca.tar.gz apache-33945303367244830fdd8d67d9987ad3721049ca.tar.bz2 apache-33945303367244830fdd8d67d9987ad3721049ca.tar.xz apache-33945303367244830fdd8d67d9987ad3721049ca.zip |
parametrization
Diffstat (limited to '2.4/Dockerfile')
-rw-r--r-- | 2.4/Dockerfile | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/2.4/Dockerfile b/2.4/Dockerfile index 52e7104..87a63d4 100644 --- a/2.4/Dockerfile +++ b/2.4/Dockerfile @@ -1,13 +1,26 @@ 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. - apk add --no-cache openssl; \ - apk add --no-cache apr-util-dbm_db; \ + 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. @@ -17,44 +30,38 @@ RUN set -ex; \ 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"; \ - # Enable DAV modules. - for i in dav dav_fs; do \ - sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" "conf/httpd.conf"; \ - done; \ - \ # Make sure authentication modules are enabled. - for i in authn_core authn_file authz_core authz_user auth_basic auth_digest; do \ - sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" "conf/httpd.conf"; \ - done; \ - \ - # Make sure other modules are enabled. - for i in alias headers mime setenvif; do \ + 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; \ \ - # Run httpd as "www-data" (instead of "daemon"). - #for i in User Group; do \ - # sed -i -e "s|^$i .*|$i www-data|" "conf/httpd.conf"; \ - #done; \ - \ # Include enabled configs and sites. + printf '%s\n' "PidFile /tmp/httpd.pid" \ + >> "conf/httpd.conf"; \ printf '%s\n' "Include conf/conf-enabled/*.conf" \ >> "conf/httpd.conf"; \ printf '%s\n' "Include conf/sites-enabled/*.conf" \ - >> "conf/httpd.conf" - -COPY conf/ conf/ - -RUN set -ex; \ - # Enable dav and default site. + >> "conf/httpd.conf"; \ + # Enable module configuration and default site. mkdir -p "conf/conf-enabled"; \ mkdir -p "conf/sites-enabled"; \ - ln -s ../conf-available/dav.conf "conf/conf-enabled"; \ - ln -s ../conf-available/pid.conf "conf/conf-enabled"; \ + for i in $modules; do \ + if [ -f ../conf-available/${i}.conf ]; then \ + ln -s ../conf-available/${i}.conf "conf/conf-enabled"; \ + fi; \ + done; \ ln -s ../sites-available/default.conf "conf/sites-enabled" -COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh - EXPOSE 8080/tcp 8043/tcp ENTRYPOINT [ "docker-entrypoint.sh" ] CMD [ "httpd-foreground" ] |