forked from devilbox/docker-apache-2.4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
162 lines (139 loc) · 4.19 KB
/
Dockerfile
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
FROM httpd:2.4
MAINTAINER "sixfoot3" <tom@sixfoot3.com>
LABEL \
name="cytopia's apache 2.4 image with catalina edits" \
image="tmort/apache-2.4" \
vendor="sixfoot3" \
license="MIT"
###
### Build arguments
###
ARG VHOST_GEN_GIT_REF=0.15
ARG CERT_GEN_GIT_REF=0.2
ENV BUILD_DEPS \
git \
make \
wget
ENV RUN_DEPS \
ca-certificates \
python-yaml \
supervisor
###
### Runtime arguments
###
ENV MY_USER=daemon
ENV MY_GROUP=daemon
ENV HTTPD_START="httpd-foreground"
ENV HTTPD_RELOAD="/usr/local/apache2/bin/httpd -k stop"
###
### Install required packages
###
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
${BUILD_DEPS} \
${RUN_DEPS} \
\
# Install vhost-gen
&& git clone https://github.com/devilbox/vhost-gen \
&& cd vhost-gen \
&& git checkout "${VHOST_GEN_GIT_REF}" \
&& make install \
&& cd .. \
&& rm -rf vhost*gen* \
\
# Install cert-gen
&& wget --no-check-certificate -O /usr/bin/ca-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/ca-gen \
&& wget --no-check-certificate -O /usr/bin/cert-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/cert-gen \
&& chmod +x /usr/bin/ca-gen \
&& chmod +x /usr/bin/cert-gen \
\
# Install watcherd
&& wget --no-check-certificate -O /usr/bin/watcherd https://raw.githubusercontent.com/devilbox/watcherd/master/watcherd \
&& chmod +x /usr/bin/watcherd \
\
# Clean-up
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps \
${BUILD_DEPS} \
&& rm -rf /var/lib/apt/lists/*
###
### Configure Apache
###
RUN set -x \
&& APACHE_VERSION="$( httpd -V | grep -Eo 'Apache/[.0-9]+' | awk -F'/' '{print $2}' )" \
&& ( \
echo "ServerName localhost"; \
\
echo "LoadModule http2_module modules/mod_http2.so"; \
echo "LoadModule proxy_module modules/mod_proxy.so"; \
echo "LoadModule proxy_http_module modules/mod_proxy_http.so"; \
echo "LoadModule proxy_http2_module modules/mod_proxy_http2.so"; \
echo "LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so"; \
echo "LoadModule rewrite_module modules/mod_rewrite.so"; \
\
echo "Include conf/extra/httpd-default.conf"; \
echo "IncludeOptional /etc/httpd-custom.d/*.conf"; \
echo "IncludeOptional /etc/httpd/conf.d/*.conf"; \
echo "IncludeOptional /etc/httpd/vhost.d/*.conf"; \
\
echo "LoadModule ssl_module modules/mod_ssl.so"; \
echo "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" ;\
echo "Listen 443"; \
echo "SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
echo "SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
echo "SSLHonorCipherOrder on"; \
echo "SSLProtocol all -SSLv3"; \
echo "SSLProxyProtocol all -SSLv3"; \
echo "SSLPassPhraseDialog builtin"; \
echo "SSLSessionCache \"shmcb:/usr/local/apache2/logs/ssl_scache(512000)\""; \
echo "SSLSessionCacheTimeout 300"; \
\
echo "<If \"%{THE_REQUEST} =~ m#^.*HTTP/1\.0\$#\">"; \
echo " Header always set Via \"1.0 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \
echo "</If>"; \
echo "<If \"%{THE_REQUEST} =~ m#^.*HTTP/1\.1\$#\">"; \
echo " Header always set Via \"1.1 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \
echo "</If>"; \
echo "<If \"%{THE_REQUEST} =~ m#^.*HTTP/2\.0\$#\">"; \
echo " Header always set Via \"2.0 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \
echo "</If>"; \
\
echo "HTTPProtocolOptions unsafe"; \
) >> /usr/local/apache2/conf/httpd.conf
###
### Create directories
###
RUN set -x \
&& mkdir -p /etc/httpd-custom.d \
&& mkdir -p /etc/httpd/conf.d \
&& mkdir -p /etc/httpd/vhost.d \
&& mkdir -p /var/www/default/htdocs \
&& mkdir -p /shared/httpd \
&& chmod 0775 /shared/httpd \
&& chown ${MY_USER}:${MY_GROUP} /shared/httpd
###
### Copy files
###
COPY ./data/vhost-gen/main.yml /etc/vhost-gen/main.yml
COPY ./data/vhost-gen/mass.yml /etc/vhost-gen/mass.yml
COPY ./data/create-vhost.sh /usr/local/bin/create-vhost.sh
COPY ./data/docker-entrypoint.d /docker-entrypoint.d
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
###
### Ports
###
EXPOSE 80
EXPOSE 443
###
### Volumes
###
VOLUME /shared/httpd
VOLUME /ca
###
### Signals
###
STOPSIGNAL SIGTERM
###
### Entrypoint
###
ENTRYPOINT ["/docker-entrypoint.sh"]