-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
163 lines (155 loc) · 5.47 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
163
FROM debian:buster-slim
LABEL name="httpd-svn" \
description="Apache httpd with Subversion" \
maintainer="[email protected]" \
version="2.4.41-1.12.2-01"
ENV HTTPD_VERSION 2.4.41
ENV HTTPD_SHA256 133d48298fe5315ae9366a0ec66282fa4040efa5d566174481077ade7d18ea40
ENV SVN_VERSION 1.12.2
ENV SVN_SHA512 b1f859b460afa54598778d8633f648acb4fa46138f7d6f0c1451e3c6a1de71df859233cd9ac7f19f0f20d7237ed3988f0a38da7552ffa58391e19d957bc7c136
ENV HTTPD_PREFIX /usr/local/apache2
ENV PATH $HTTPD_PREFIX/bin:$PATH
RUN groupadd -r httpd && useradd -r -g httpd httpd \
&& mkdir -p /svn/repos \
&& mkdir -p /svn/config \
&& mkdir -p /svn/backup \
&& chown -R httpd:httpd /svn/repos
COPY conf/* /svn/config/
VOLUME ["/svn"]
WORKDIR $HTTPD_PREFIX
# https://httpd.apache.org/security/vulnerabilities_24.html
ENV HTTPD_PATCHES=""
ENV APACHE_DIST_URLS \
# https://issues.apache.org/jira/browse/INFRA-8753?focusedCommentId=14735394#comment-14735394
https://www.apache.org/dyn/closer.cgi?action=download&filename= \
# if the version is outdated (or we're grabbing the .asc file), we might have to pull from the dist/archive :/
https://www-us.apache.org/dist/ \
https://www.apache.org/dist/ \
https://archive.apache.org/dist/
# see https://httpd.apache.org/docs/2.4/install.html#requirements
# plus libsqlite3-dev for svn
RUN set -eux; \
runtimeDeps=" \
ca-certificates \
bzip2 \
libsqlite3-0 \
ssl-cert \
zlib1g \
libapr1 \
libaprutil1 \
libaprutil1-ldap \
liblua5.2 \
libxml2 \
"; \
buildDeps=" \
dpkg-dev \
dirmngr \
gcc \
gnupg \
libapr1-dev \
libaprutil1-dev \
liblua5.2-dev \
libnghttp2-dev \
libpcre3-dev \
libssl-dev \
libsqlite3-dev \
libxml2-dev \
zlib1g-dev \
make \
wget \
"; \
usefulTools=" \
net-tools \
"; \
apt-get update; \
apt-get install -y --no-install-recommends -V $buildDeps $runtimeDeps $usefulTools; \
rm -r /var/lib/apt/lists/*; \
\
ddist() { \
local f="$1"; shift; \
local distFile="$1"; shift; \
local success=; \
local distUrl=; \
for distUrl in $APACHE_DIST_URLS; do \
if wget -O "$f" "$distUrl$distFile" && [ -s "$f" ]; then \
success=1; \
break; \
fi; \
done; \
[ -n "$success" ]; \
}; \
\
ddist 'httpd.tar.bz2' "httpd/httpd-$HTTPD_VERSION.tar.bz2"; \
echo "$HTTPD_SHA256 *httpd.tar.bz2" | sha256sum -c -; \
ddist 'subversion.tar.bz2' "subversion/subversion-$SVN_VERSION.tar.bz2"; \
echo "$SVN_SHA512 *subversion.tar.bz2" | sha512sum -c -; \
\
# see https://httpd.apache.org/download.cgi#verify
ddist 'httpd.tar.bz2.asc' "httpd/httpd-$HTTPD_VERSION.tar.bz2.asc"; \
ddist 'subversion.tar.bz2.asc' "subversion/subversion-$SVN_VERSION.tar.bz2.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf; \
for key in \
# gpg: key 791485A8: public key "Jim Jagielski (Release Signing Key) <[email protected]>" imported
A93D62ECC3C8EA12DB220EC934EA76E6791485A8 \
# gpg: key 995E35221AD84DFF: public key "Daniel Ruggeri (http://home.apache.org/~druggeri/) <[email protected]>" imported
B9E8213AEFB861AF35A41F2C995E35221AD84DFF \
; do \
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done; \
gpg --batch --verify httpd.tar.bz2.asc httpd.tar.bz2; \
wget -O subversion.asc https://people.apache.org/keys/group/subversion.asc; \
gpg --import subversion.asc; \
gpg --batch --verify subversion.tar.bz2.asc subversion.tar.bz2; \
rm -rf "$GNUPGHOME" httpd.tar.bz2.asc subversion.asc subversion.tar.bz2.asc; \
\
mkdir -p src; \
tar -xf httpd.tar.bz2 -C src --strip-components=1; \
rm httpd.tar.bz2; \
cd src; \
\
patches() { \
while [ "$#" -gt 0 ]; do \
local patchFile="$1"; shift; \
local patchSha256="$1"; shift; \
ddist "$patchFile" "httpd/patches/apply_to_$HTTPD_VERSION/$patchFile"; \
echo "$patchSha256 *$patchFile" | sha256sum -c -; \
patch -p0 < "$patchFile"; \
rm -f "$patchFile"; \
done; \
}; \
patches $HTTPD_PATCHES; \
\
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--prefix="$HTTPD_PREFIX" \
--enable-mods-shared=reallyall \
--enable-mpms-shared=all \
; \
make -j "$(nproc)"; \
make install; \
cd ..; \
\
mkdir -p src-svn; \
tar -xf subversion.tar.bz2 -C src-svn --strip-components=1; \
rm subversion.tar.bz2; \
cd src-svn; \
./configure --with-lz4=internal --with-utf8proc=internal \
--enable-mod-activation --with-apxs \
--with-apache-libexecdir=/usr/local/apache2/modules; \
make; \
make install; \
\
cd ..; \
rm -r src src-svn man manual; \
apt-get purge -y --auto-remove $buildDeps; \
make-ssl-cert generate-default-snakeoil; \
mkdir -p /etc/ssl/localcerts; \
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/localcerts/server.key; \
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/localcerts/server.crt; \
rm -f $HTTPD_PREFIX/conf/httpd.conf; \
ln -s /svn/config/httpd.conf $HTTPD_PREFIX/conf/httpd.conf
COPY scripts/*.sh /usr/local/bin/
EXPOSE 80 443
CMD ["httpd-foreground.sh"]