summaryrefslogtreecommitdiffstats
path: root/2.4/Dockerfile
blob: 9074b191d12a61e19674fdcfb522030443118114 (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
74
75
76
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 /etc/apache2/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" ]