|
1 | | -# -------- builder: lua/ndk dynamic modules for nginx 1.27.4 (PCRE2) -------- |
2 | | -FROM nginx:1.27.4 AS lua-builder |
| 1 | +# --- minimal builder for ndk + lua modules (nginx 1.27.4, PCRE2) --- |
| 2 | +FROM nginx:1.27.4 AS build |
3 | 3 |
|
4 | | -# Мінімум потрібного + інструменти для саніті-чеків (objdump/readelf) |
5 | 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
6 | 5 | build-essential pkg-config \ |
7 | | - libpcre2-dev zlib1g-dev libssl-dev libreadline-dev \ |
8 | | - git wget ca-certificates binutils \ |
| 6 | + libpcre2-dev zlib1g-dev libssl-dev \ |
| 7 | + git wget ca-certificates \ |
9 | 8 | && rm -rf /var/lib/apt/lists/* |
10 | 9 |
|
11 | 10 | WORKDIR /usr/src |
12 | 11 |
|
13 | | -# ---- LuaJIT (runtime буде підсовуватись окремо/системний) ---- |
| 12 | +# LuaJIT (потрібен для збірки lua-модуля) |
14 | 13 | RUN git clone --branch v2.1-agentzh --single-branch https://github.com/openresty/luajit2.git |
15 | 14 | WORKDIR /usr/src/luajit2 |
16 | 15 | RUN make -j"$(nproc)" && make install |
17 | 16 |
|
18 | | -ENV PATH="/usr/local/bin:${PATH}" |
19 | | -ENV LD_LIBRARY_PATH="/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| 17 | +ENV LUAJIT_LIB=/usr/local/lib |
| 18 | +ENV LUAJIT_INC=/usr/local/include/luajit-2.1 |
20 | 19 |
|
21 | | -# ---- NDK + lua-nginx-module (сумісні з 1.27.x) ---- |
22 | | -WORKDIR /usr/src |
| 20 | +# NDK + lua-nginx-module (версії сумісні з 1.27.x) |
23 | 21 | ARG NDK_V=v0.3.3 |
24 | 22 | ARG LUA_NGX_V=v0.10.27 |
| 23 | +WORKDIR /usr/src |
25 | 24 | RUN git clone --branch "${NDK_V}" --single-branch https://github.com/simpl/ngx_devel_kit.git |
26 | 25 | RUN git clone --branch "${LUA_NGX_V}" --single-branch https://github.com/openresty/lua-nginx-module.git |
27 | 26 |
|
28 | | -# ---- NGINX sources (точно 1.27.4) ---- |
| 27 | +# NGINX sources рівно 1.27.4 |
29 | 28 | ARG NGINX_V=1.27.4 |
30 | 29 | RUN wget -O "nginx-${NGINX_V}.tar.gz" "http://nginx.org/download/nginx-${NGINX_V}.tar.gz" \ |
31 | 30 | && tar zxf "nginx-${NGINX_V}.tar.gz" |
32 | 31 |
|
33 | 32 | WORKDIR /usr/src/nginx-${NGINX_V} |
34 | 33 |
|
35 | | -# LuaJIT include/lib for lua-nginx-module |
36 | | -ENV LUAJIT_LIB=/usr/local/lib |
37 | | -ENV LUAJIT_INC=/usr/local/include/luajit-2.1 |
38 | | - |
39 | | -# ВАЖЛИВО: НЕ додаємо --with-pcre=..., авто-детект підійме PCRE2 з libpcre2-dev |
| 34 | +# Збірка динамічних модулів (без --with-pcre=*, авто PCRE2) |
40 | 35 | RUN ./configure --with-compat \ |
41 | 36 | --add-dynamic-module=../ngx_devel_kit \ |
42 | 37 | --add-dynamic-module=../lua-nginx-module \ |
43 | | - --with-ld-opt="-Wl,-rpath,/usr/local/lib" \ |
44 | | - || { echo '--- autoconf.err ---'; cat objs/autoconf.err 2>/dev/null || true; exit 1; } |
45 | | - |
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' |
| 38 | + --with-ld-opt="-Wl,-rpath,/usr/local/lib" |
| 39 | +RUN make modules -j"$(nproc)" |
| 40 | + |
| 41 | +# --- stage із артефактами, щоб легко вивантажити їх локально --- |
| 42 | +FROM scratch AS out |
| 43 | +COPY --from=build /usr/src/nginx-1.27.4/objs/ndk_http_module.so /artifacts/ndk_http_module.so |
| 44 | +COPY --from=build /usr/src/nginx-1.27.4/objs/ngx_http_lua_module.so /artifacts/ngx_http_lua_module.so |
| 45 | +# якщо хочеш самодостатній рантайм без apt: |
| 46 | +COPY --from=build /usr/local/lib/libluajit-5.1.so.2 /artifacts/libluajit-5.1.so.2 |
0 commit comments