-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·76 lines (69 loc) · 2.53 KB
/
build.sh
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
#!/bin/bash
#########################################################################
# Builds a particular NGINX version for a particular Linux OS and version
#########################################################################
NGINX_VERSION=${NGINX_VERSION:-1.25.5}
NGINX_TARBALL=nginx-${NGINX_VERSION}.tar.gz
LINUX_DISTRO=${LINUX_DISTRO:-alpine}
if [ "$LINUX_DISTRO" != 'alpine' ] &&
[ "$LINUX_DISTRO" != 'debian11' ] &&
[ "$LINUX_DISTRO" != 'debian12' ] &&
[ "$LINUX_DISTRO" != 'ubuntu18' ] &&
[ "$LINUX_DISTRO" != 'ubuntu20' ] &&
[ "$LINUX_DISTRO" != 'ubuntu22' ] &&
[ "$LINUX_DISTRO" != 'ubuntu24' ] &&
[ "$LINUX_DISTRO" != 'amazon2' ] &&
[ "$LINUX_DISTRO" != 'amazon2023' ] &&
[ "$LINUX_DISTRO" != 'centosstream9' ]; then
echo "$LINUX_DISTRO is not a supported Linux distribution"
exit 1
fi
function getLibraryPrefix() {
if [ "$LINUX_DISTRO" == 'alpine' ]; then
echo 'alpine'
elif [ "$LINUX_DISTRO" == 'debian11' ]; then
echo 'debian.bullseye'
elif [ "$LINUX_DISTRO" == 'debian12' ]; then
echo 'debian.bookworm'
elif [ "$LINUX_DISTRO" == 'ubuntu18' ]; then
echo 'ubuntu.18.04'
elif [ "$LINUX_DISTRO" == 'ubuntu20' ]; then
echo 'ubuntu.20.04'
elif [ "$LINUX_DISTRO" == 'ubuntu22' ]; then
echo 'ubuntu.22.04'
elif [ "$LINUX_DISTRO" == 'ubuntu24' ]; then
echo 'ubuntu.24.04'
elif [ "$LINUX_DISTRO" == 'amazon2' ]; then
echo 'amzn2'
elif [ "$LINUX_DISTRO" == 'amazon2023' ]; then
echo 'amzn2023'
elif [ "$LINUX_DISTRO" == 'centosstream9' ]; then
echo 'centos.stream.9'
fi
}
if [[ ! -r $NGINX_TARBALL ]]; then
if [ -z "$DOWNLOAD_PROGRAM" ]; then
if hash curl &>/dev/null; then
DOWNLOAD_PROGRAM="curl -O"
elif hash wget &>/dev/null; then
DOWNLOAD_PROGRAM="wget"
else
echo "Couldn't find curl or wget, please install either of these programs."
exit 1
fi
fi
$DOWNLOAD_PROGRAM https://nginx.org/download/nginx-"${NGINX_VERSION}".tar.gz
fi
docker build -t nginx-module-builder \
--build-arg NGINX_VERSION="$NGINX_VERSION" \
-f builders/$LINUX_DISTRO.Dockerfile .
if [ $? -ne 0 ]; then
echo "Docker build problem encountered for OS $LINUX_DISTRO and NGINX $NGINX_VERSION"
exit 1
fi
mkdir -p build
LIBRARY_PREFIX=$(getLibraryPrefix)
docker run --name nginx-modules nginx-module-builder
docker cp nginx-modules:/tmp/nginx-$NGINX_VERSION/objs/ngx_curity_http_phantom_token_module.so ./build/$LIBRARY_PREFIX.ngx_curity_http_phantom_token_module_$NGINX_VERSION.so
docker rm nginx-modules
docker rmi nginx-module-builder