forked from wolfi-dev/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apache2.yaml
311 lines (271 loc) · 10.3 KB
/
apache2.yaml
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
package:
name: apache2
version: 2.4.62
epoch: 5
description: "Apache HTTP Server"
copyright:
- license: Apache-2.0
dependencies:
runtime:
- libgcc
- lua5.4
environment:
contents:
packages:
- apr-util-dev
- autoconf
- automake
- brotli-dev
- build-base
- libapr-dev
- libxml2-dev
- lua5.4-dev
- nghttp2-dev
- openssf-compiler-options
- openssl-dev
- pcre2-dev
- readline-dev
- wolfi-base
- zlib-dev
pipeline:
- uses: git-checkout
with:
expected-commit: f4c1e18ead5d642698034b831121cbb82b55f60e
repository: https://github.com/apache/httpd
tag: ${{package.version}}
- runs: |
set -x
./buildconf --with-apr=/usr/bin/apr-1-config
mv configure.in configure.ac
- uses: autoconf/configure
with:
opts: |
--prefix=/ \
--enable-layout=Debian \
--sysconfdir=/etc/apache2 \
--enable-so \
--enable-suexec \
--with-suexec-caller=www-data \
--with-suexec-docroot=/var/www \
--with-suexec-logfile=/var/log/apache2/suexec.log \
--with-suexec-bin=/usr/sbin/suexec \
--with-suexec-uidmin=99 \
--with-suexec-gidmin=99 \
--with-apr=/usr/bin/apr-1-config \
--with-apr-util=/usr/bin/apu-1-config \
--with-pcre=/usr \
--enable-mods-shared=all \
--enable-mpms-shared=all \
--with-mpm=prefork \
--enable-ssl \
--with-ssl \
--enable-proxy \
--enable-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-file-cache \
--enable-ldap \
--enable-authnz-ldap \
--enable-cgid \
--enable-cgi \
--enable-authn-anon \
--enable-authn-alias \
--disable-imagemap \
--enable-proxy-connect \
--enable-proxy-http \
--enable-proxy-ftp \
--enable-deflate \
--enable-dbd \
--enable-exception-hook \
--enable-dav \
--enable-dav-fs \
--enable-dav-lock
- uses: autoconf/make
- uses: autoconf/make-install
- uses: strip
subpackages:
- name: ${{package.name}}-dev
description: "Apache HTTP Server (development headers)"
pipeline:
- uses: split/dev
dependencies:
runtime:
- perl
- apr-util-dev
- name: ${{package.name}}-doc
description: "Apache HTTP Server (documentation)"
pipeline:
- uses: split/manpages
- runs: |
set -x
mkdir -p "${{targets.subpkgdir}}"/usr/share/doc/apache2
mv "${{targets.destdir}}"/usr/share/apache2/default-site/htdocs/manual "${{targets.subpkgdir}}"/usr/share/doc/apache2/
- name: ${{package.name}}-utils
description: "Apache HTTP Server (utilities)"
pipeline:
- runs: |
set -x
# Move utilities to usr/bin
mkdir -p "${{targets.subpkgdir}}"/usr/bin
for i in ab htdbm htdigest htpasswd httxt2dbm logresolve; do
mv "${{targets.destdir}}"/usr/bin/$i "${{targets.subpkgdir}}"/usr/bin/
done
# Move utilities to usr/sbin
mkdir -p "${{targets.subpkgdir}}"/usr/sbin
for i in checkgid fcgistarter htcacheclean rotatelogs; do
mv "${{targets.destdir}}"/usr/sbin/$i "${{targets.subpkgdir}}"/usr/sbin/
done
- name: ${{package.name}}-data
description: "Apache HTTP Server (data files)"
pipeline:
- runs: |
mkdir -p "${{targets.subpkgdir}}"/usr/share/apache2
mv "${{targets.destdir}}"/usr/share/apache2/icons "${{targets.subpkgdir}}"/usr/share/apache2/
mv "${{targets.destdir}}"/usr/share/apache2/error "${{targets.subpkgdir}}"/usr/share/apache2/
- name: ${{package.name}}-compat
description: "Config compatibility to upstream docker image"
dependencies:
runtime:
- ${{package.name}}
- dash-binsh
pipeline:
- runs: |
set -x
# Install the entrypoint script
install -Dm755 entrypoint.sh "${{targets.subpkgdir}}"/usr/bin/entrypoint.sh
# Create necessary folders
mkdir -p "${{targets.subpkgdir}}"/usr/local/apache2/
mkdir -p "${{targets.subpkgdir}}"/usr/local/apache2/conf
mkdir -p "${{targets.subpkgdir}}"/usr/local/apache2/var/run/apache2
mkdir -p "${{targets.subpkgdir}}"/usr/local/apache2/logs
# Install necessary config files
mkdir -p "${{targets.subpkgdir}}"/etc/apache2
cp "${{targets.destdir}}"/etc/apache2/original/httpd.conf "${{targets.subpkgdir}}"/etc/apache2
cp -r "${{targets.destdir}}"/etc/apache2/original/extra/ "${{targets.subpkgdir}}"/etc/apache2
# Create symlinks
ln -s /etc/apache2/httpd.conf "${{targets.subpkgdir}}"/usr/local/apache2/conf/
ln -s /etc/apache2/extra "${{targets.subpkgdir}}"/usr/local/apache2/conf/
ln -s /etc/apache2/mime.types "${{targets.subpkgdir}}"/usr/local/apache2/conf/
ln -s /etc/apache2/magic "${{targets.subpkgdir}}"/usr/local/apache2/conf/
ln -s /usr/lib/apache2/modules/ "${{targets.subpkgdir}}"/usr/local/apache2/
ln -s /usr/share/apache2/default-site/htdocs "${{targets.subpkgdir}}"/usr/local/apache2/
ln -s /usr/lib/cgi-bin/ "${{targets.subpkgdir}}"/usr/local/apache2/
# Modify User/Group and verify changes are applied.
sed -ri \
-e 's!^(\s*User)\s+daemon\s*$!\1 www-data!g' \
-e 's!^(\s*Group)\s+daemon\s*$!\1 www-data!g' \
"${{targets.subpkgdir}}"/etc/apache2/httpd.conf
# Modify CustomLog/ErrorLog and verify changes are applied
sed -ri \
-e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \
-e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \
-e 's!^(\s*TransferLog)\s+\S+!\1 /proc/self/fd/1!g' \
"${{targets.subpkgdir}}"/etc/apache2/httpd.conf \
"${{targets.subpkgdir}}"/etc/apache2/extra/httpd-ssl.conf;
# Modify module config to match upstream docker
sed -ri \
-e '/LoadModule mpm_prefork_module/s/^/#/g' \
-e '/LoadModule mpm_event_module/s/^#//g' \
"${{targets.subpkgdir}}"/etc/apache2/httpd.conf
### Modify other paths to match upstream default config
sed -ri \
-e 's!^(\s*ServerRoot)\s+\S+!\1 "/usr/local/apache2"!g' \
-e 's|usr/lib/apache2/modules|modules|g' \
-e 's|etc/apache2/mime.types|conf/mime.types|g' \
-e 's|usr/share/apache2/default-site/htdocs|usr/local/apache2/htdocs|g' \
-e 's|usr/lib/cgi-bin|usr/local/apache2/cgi-bin|g' \
-e 's|etc/apache2/extra|conf/extra|g' \
-e 's|etc/apache2/magic|conf/magic|g' \
"${{targets.subpkgdir}}"/etc/apache2/httpd.conf \
"${{targets.subpkgdir}}"/etc/apache2/extra/httpd-ssl.conf;
### Modify other paths
sed -ri \
-e 's|etc/|usr/local/apache2/conf/|g' \
-e 's|/var/run/apache2/|usr/local/apache2/logs/|g' \
"${{targets.subpkgdir}}"/etc/apache2/extra/httpd-ssl.conf;
test:
environment:
contents:
packages:
- curl
pipeline:
- runs: |
# Verify config is as expected upstream docker instance
grep -E '^\s*User www-data$' /usr/local/apache2/conf/httpd.conf;
grep -E '^\s*Group www-data$' /usr/local/apache2/conf/httpd.conf;
grep -E '^\s*ErrorLog /proc/self/fd/2$' /usr/local/apache2/conf/httpd.conf;
grep -E '^\s*ErrorLog /proc/self/fd/2$' /usr/local/apache2/conf/extra/httpd-ssl.conf;
grep -E '^\s*CustomLog /proc/self/fd/1' /usr/local/apache2/conf/httpd.conf;
grep -E '^\s*CustomLog /proc/self/fd/1' /usr/local/apache2/conf/extra/httpd-ssl.conf;
grep -E '^\s*TransferLog /proc/self/fd/1$' /usr/local/apache2/conf/extra/httpd-ssl.conf;
adduser -D -H www-data
httpd -M
echo "<html><body><h1>Apache Test Page</h1></body></html>" > /usr/local/apache2/htdocs/test.html
# Start httpd using the custom configuration
echo "Starting httpd..."
httpd -DFOREGROUND &
httpd_pid=$!
# Give httpd some time to start
sleep 5
# Test if httpd is running
if pgrep httpd > /dev/null; then
echo "PASS: Apache (httpd) is running."
else
echo "FAIL: Apache (httpd) is not running."
kill "$httpd_pid"
exit 1
fi
# Test serving the page using curl
echo "Testing the page with curl..."
curl -v http://localhost/test.html 2>&1 | tee /tmp/curl_output.log
if grep "200 OK" /tmp/curl_output.log > /dev/null; then
echo "PASS: Page served successfully."
else
echo "FAIL: Could not retrieve the page. Check curl output:"
cat /tmp/curl_output.log
fi
# Stop httpd
echo "Stopping httpd..."
kill "$httpd_pid"
test:
environment:
contents:
packages:
- curl
pipeline:
- runs: |
apachectl -v
httpd -v
httpd -M
echo "<html><body><h1>Apache Test Page</h1></body></html>" > /usr/share/apache2/default-site/htdocs/test.html
# Start httpd using the custom configuration
echo "Starting httpd..."
httpd -DFOREGROUND &
httpd_pid=$!
# Give httpd some time to start
sleep 5
# Test if httpd is running
if pgrep httpd > /dev/null; then
echo "PASS: Apache (httpd) is running."
else
echo "FAIL: Apache (httpd) is not running."
kill "$httpd_pid"
exit 1
fi
# Test serving the page using curl
echo "Testing the page with curl..."
curl -v http://localhost/test.html 2>&1 | tee /tmp/curl_output.log
if grep "200 OK" /tmp/curl_output.log > /dev/null; then
echo "PASS: Page served successfully."
else
echo "FAIL: Could not retrieve the page. Check curl output:"
cat /tmp/curl_output.log
fi
# Stop httpd
echo "Stopping httpd..."
kill "$httpd_pid"
update:
enabled: true
github:
identifier: apache/httpd
use-tag: true