-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (144 loc) · 6.56 KB
/
build_nginx.yml
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
name: Build Nginx Based
on:
workflow_dispatch:
inputs:
nginx_version:
description: "Specify the nginx version"
required: true
default: "1.27.2"
prefix:
description: "Specify the installation prefix"
required: true
default: "/usr/local/nginx"
jobs:
build-nginx:
runs-on: rockylinux-latest
env:
NGINX_SRC_DIR: "/opt/nginx"
PREFIX: ${{ github.event.inputs.prefix }}
NGINX_VERSION: ${{ github.event.inputs.nginx_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update System and Install Dependencies
run: |
sudo dnf --setopt=fastestmirror=True --setopt=deltarpm=True \
--setopt=max_parallel_downloads=10 --setopt=keepcache=True makecache &&
sudo dnf -y update &&
sudo dnf -y in epel-release &&
sudo dnf -y groupinstall "Development Tools" &&
sudo dnf -y in nano wget cmake go automake gcc gcc-c++ kernel-devel git make tar autoconf \
zlib-devel openssl-devel pcre-devel perl-IPC-Cmd libaio-devel \
brotli-devel glibc-headers glibc-devel libbsd-devel perl-core \
libxcrypt-compat libtool binutils binutils-gold
- name: Clone and Build libmaxminddb
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/maxmind/libmaxminddb.git &&
cd libmaxminddb && ./bootstrap && ./configure &&
make -j$(nproc) && sudo make install && sudo make clean
- name: Clone OpenSSL
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/quictls/openssl.git
- name: Clone and Build jemalloc
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/jemalloc/jemalloc.git &&
cd jemalloc && ./autogen.sh && ./configure &&
make -j$(nproc) && sudo make install && sudo make clean &&
sudo ln -sf /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.2
- name: Clone ngx_brotli
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/google/ngx_brotli.git &&
cd ngx_brotli && git submodule update --init
- name: Clone and Build zstd
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/facebook/zstd.git &&
cd zstd && make -j$(nproc) && sudo make install && sudo make clean
- name: Clone ngx_zstd
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/tokers/zstd-nginx-module.git
- name: Clone and Build PCRE2
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/PCRE2Project/pcre2.git &&
cd pcre2 && ./autogen.sh && ./configure &&
make -j$(nproc) && sudo make install && sudo make clean
- name: Clone ngx_http_geoip2_module
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/leev/ngx_http_geoip2_module.git
- name: Clone and Build LuaJIT2
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/openresty/luajit2.git &&
cd luajit2 && make -j$(nproc) && sudo make install && sudo make clean
- name: Clone ngx_devel_kit
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/vision5/ngx_devel_kit.git
- name: Clone lua_nginx_module
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
git clone --depth 1 --recurse-submodules https://github.com/openresty/lua-nginx-module.git
- name: Download and Extract Nginx
run: |
cd ${{ env.NGINX_SRC_DIR}} &&
wget https://nginx.org/download/nginx-${{ env.NGINX_VERSION }}.tar.gz &&
tar -zxvf nginx-${{ env.NGINX_VERSION }}.tar.gz
- name: Configure Nginx
run: |
cd ${{ env.NGINX_SRC_DIR}}/nginx-${{ env.NGINX_VERSION }} &&
sudo source ~/.bashrc && sudo ldconfig &&
sudo ./configure --prefix=${{ env.PREFIX }} \
--with-compat \
--with-threads \
--with-file-aio \
--with-http_v2_module \
--with-http_v3_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_slice_module \
--with-http_realip_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-pcre-jit \
--with-pcre=../pcre2 \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-openssl=../openssl \
--add-module=../ngx_zstd \
--add-module=../ngx_brotli \
--add-dynamic-module=../ngx_http_geoip2_module \
--with-ld-opt="-ljemalloc -lcrypt -Wl,-z,relro,-z,now -flto -fuse-ld=gold" \
--with-openssl-opt='no-weak-ssl-ciphers enable-ec_nistp_64_gcc_128 enable-tls1_3 enable-quic' \
--with-cc-opt='-O3 -march=haswell -mtune=haswell -mavx2 -funroll-loops -fprefetch-loop-arrays \
-fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -pipe -flto -fuse-ld=gold'
- name: Build Nginx
env:
NGINX_BUILD: ${{ NGINX_SRC_DIR }}/build/
run: |
sudo source ~/.bashrc && sudo ldconfig &&
cd ${{ env.NGINX_SRC_DIR}}/nginx-${{ env.NGINX_VERSION }} &&
make -j$(nproc) && sudo mkdir -p ${{ NGINX_BUILD }}
sudo objs/nginx -V &> ${{ NGINX_BUILD }}/nginx_build_info.txt &&
sudo mv objs/nginx ${{ NGINX_BUILD }} &&
sudo mv objs/ngx_http_geoip2_module.so ${{ NGINX_BUILD }}
- name: Upload Nginx binary and build information to repository
uses: actions/upload-artifact@v4
env:
NGINX_BUILD: ${{ NGINX_SRC_DIR }}/build/
with:
name: nginx-linux64-${{ env.NGINX_VERSION }}
path: |
${{ NGINX_BUILD }}/nginx
${{ NGINX_BUILD }}/nginx_build_info.txt
${{ NGINX_BUILD }}/ngx_http_geoip2_module.so
retention-days: 2
compression-level: 9
if-no-files-found: error