|
| 1 | +# -------- builder: lua/ndk dynamic modules for nginx 1.27.4 (PCRE2) -------- |
1 | 2 | FROM nginx:1.27.4 AS lua-builder |
2 | 3 |
|
3 | | -RUN apt-get update && apt-get install -y \ |
4 | | - build-essential \ |
5 | | - pkg-config \ |
6 | | - libpcre2-dev \ |
7 | | - zlib1g-dev \ |
8 | | - libssl-dev \ |
9 | | - libreadline-dev \ |
10 | | - git \ |
11 | | - wget \ |
12 | | - ca-certificates \ |
| 4 | +# Мінімум потрібного + інструменти для саніті-чеків (objdump/readelf) |
| 5 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 6 | + build-essential pkg-config \ |
| 7 | + libpcre2-dev zlib1g-dev libssl-dev libreadline-dev \ |
| 8 | + git wget ca-certificates binutils \ |
13 | 9 | && rm -rf /var/lib/apt/lists/* |
14 | 10 |
|
15 | 11 | WORKDIR /usr/src |
16 | 12 |
|
| 13 | +# ---- LuaJIT (runtime буде підсовуватись окремо/системний) ---- |
17 | 14 | RUN git clone --branch v2.1-agentzh --single-branch https://github.com/openresty/luajit2.git |
18 | 15 | WORKDIR /usr/src/luajit2 |
19 | 16 | RUN make -j"$(nproc)" && make install |
20 | 17 |
|
21 | 18 | ENV PATH="/usr/local/bin:${PATH}" |
22 | 19 | ENV LD_LIBRARY_PATH="/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
23 | 20 |
|
| 21 | +# ---- NDK + lua-nginx-module (сумісні з 1.27.x) ---- |
24 | 22 | WORKDIR /usr/src |
25 | | - |
26 | 23 | ARG NDK_V=v0.3.3 |
27 | 24 | ARG LUA_NGX_V=v0.10.27 |
28 | | -RUN git clone --branch ${NDK_V} --single-branch https://github.com/simpl/ngx_devel_kit.git |
29 | | -RUN git clone --branch ${LUA_NGX_V} --single-branch https://github.com/openresty/lua-nginx-module.git |
| 25 | +RUN git clone --branch "${NDK_V}" --single-branch https://github.com/simpl/ngx_devel_kit.git |
| 26 | +RUN git clone --branch "${LUA_NGX_V}" --single-branch https://github.com/openresty/lua-nginx-module.git |
30 | 27 |
|
| 28 | +# ---- NGINX sources (точно 1.27.4) ---- |
31 | 29 | ARG NGINX_V=1.27.4 |
32 | | -RUN wget http://nginx.org/download/nginx-${NGINX_V}.tar.gz \ |
33 | | - && tar zxf nginx-${NGINX_V}.tar.gz |
| 30 | +RUN wget -O "nginx-${NGINX_V}.tar.gz" "http://nginx.org/download/nginx-${NGINX_V}.tar.gz" \ |
| 31 | + && tar zxf "nginx-${NGINX_V}.tar.gz" |
34 | 32 |
|
35 | 33 | WORKDIR /usr/src/nginx-${NGINX_V} |
36 | 34 |
|
| 35 | +# LuaJIT include/lib for lua-nginx-module |
37 | 36 | ENV LUAJIT_LIB=/usr/local/lib |
38 | 37 | ENV LUAJIT_INC=/usr/local/include/luajit-2.1 |
39 | 38 |
|
| 39 | +# ВАЖЛИВО: НЕ додаємо --with-pcre=..., авто-детект підійме PCRE2 з libpcre2-dev |
40 | 40 | RUN ./configure --with-compat \ |
41 | 41 | --add-dynamic-module=../ngx_devel_kit \ |
42 | 42 | --add-dynamic-module=../lua-nginx-module \ |
43 | 43 | --with-ld-opt="-Wl,-rpath,/usr/local/lib" \ |
44 | 44 | || { echo '--- autoconf.err ---'; cat objs/autoconf.err 2>/dev/null || true; exit 1; } |
45 | 45 |
|
46 | | -RUN make modules -j"$(nproc)" V=1 || { echo '--- make failed ---'; exit 1; } |
| 46 | +# Переконаймося, що NGINX побачив PCRE2 |
| 47 | +RUN grep -q '^[[:space:]]*#define[[:space:]]\+NGX_PCRE2[[:space:]]\+1' objs/ngx_auto_config.h \ |
| 48 | + || { echo 'ERROR: NGX_PCRE2 not defined. PCRE2 was not detected.'; exit 1; } |
| 49 | + |
| 50 | +# Збираємо модулі з докладним логом |
| 51 | +RUN make modules -j"$(nproc)" V=1 |
| 52 | + |
| 53 | +# Саніті-чек: у готовому .so НЕ повинно бути символів pcre_* |
| 54 | +RUN objdump -T objs/ngx_http_lua_module.so | grep -i '\bpcre_' && { echo 'ERROR: lua module links to PCRE1 symbols'; exit 1; } || true |
| 55 | +RUN readelf -d objs/ngx_http_lua_module.so | grep -i 'NEEDED.*libpcre' && { echo 'ERROR: lua module NEEDS libpcre (PCRE1)'; exit 1; } || true |
| 56 | + |
| 57 | +# Викладаємо артефакти у зрозуміле місце |
| 58 | +RUN mkdir -p /artifacts |
| 59 | +RUN install -m 0644 objs/ndk_http_module.so /artifacts/ndk_http_module.so |
| 60 | +RUN install -m 0644 objs/ngx_http_lua_module.so /artifacts/ngx_http_lua_module.so |
| 61 | +# додатково: покладемо runtime-лібу LuaJIT (якщо хочеш самодостатній артефакт) |
| 62 | +RUN install -m 0644 /usr/local/lib/libluajit-5.1.so.2 /artifacts/libluajit-5.1.so.2 || true |
| 63 | + |
| 64 | +# Маніфест + SHA256 — корисно для перевірок у “основному” образі/CI |
| 65 | +RUN sh -c 'cat > /artifacts/manifest.yaml <<EOF\nmodule_set:\n nginx_version: "'"${NGINX_V}"'"\n ndk_version: "'"${NDK_V}"'"\n lua_module_version: "'"${LUA_NGX_V}"'"\n pcre2: true\n built_with_compat: true\n luajit: "2.1 (openresty/luajit2)"\nartifacts:\n - ndk_http_module.so\n - ngx_http_lua_module.so\n - libluajit-5.1.so.2\nEOF' |
| 66 | +RUN sh -c 'cd /artifacts && sha256sum * > SHA256SUMS' |
0 commit comments