summaryrefslogtreecommitdiffstats
path: root/2.4/Dockerfile
blob: e33ff5d0be62f2005bd154c50406d109636badf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM httpd:alpine

ARG ENABLE_PROXY=0
ARG ENABLE_DAV=0
ARG ENABLE_PHP=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_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"; \
    \
    # 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_PHP} -ne 0 ]; then \
        modules="$modules php7"; \
    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" ]