Skip to content

Commit 63d43ed

Browse files
committed
Update LUA new-tag
1 parent caea80d commit 63d43ed

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

build/Dockerfile.luam

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,35 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
88

99
WORKDIR /usr/src
1010

11+
# ----------------------------
12+
# LuaJIT
13+
# ----------------------------
1114
RUN git clone --branch v2.1-agentzh --single-branch https://github.com/openresty/luajit2.git
1215
WORKDIR /usr/src/luajit2
1316
RUN make -j"$(nproc)" && make install
1417

1518
ENV LUAJIT_LIB=/usr/local/lib
1619
ENV LUAJIT_INC=/usr/local/include/luajit-2.1
1720

21+
# ----------------------------
22+
# lua-cjson (cjson.so + cjson/safe.lua)
23+
# ----------------------------
1824
ARG LUA_CJSON_V=2.1.0.10
1925
WORKDIR /usr/src
2026
RUN git clone --branch "${LUA_CJSON_V}" --single-branch https://github.com/openresty/lua-cjson.git
2127
WORKDIR /usr/src/lua-cjson
2228
RUN make -j"$(nproc)" LUA_INCLUDE_DIR="${LUAJIT_INC}" \
2329
&& make install LUA_INCLUDE_DIR="${LUAJIT_INC}" LUA_LIB_DIR="${LUAJIT_LIB}"
24-
RUN install -d /usr/local/share/lua/5.1/cjson \
25-
&& cp -v /usr/src/lua-cjson/lua/cjson/*.lua /usr/local/share/lua/5.1/cjson/
2630

31+
# Copy Lua helpers if present (util.lua etc.), and always provide safe.lua
2732
RUN set -eux; \
2833
install -d /usr/local/share/lua/5.1/cjson; \
2934
if [ -d /usr/src/lua-cjson/lua/cjson ]; then \
3035
find /usr/src/lua-cjson/lua/cjson -maxdepth 1 -type f -name '*.lua' -exec cp -v {} /usr/local/share/lua/5.1/cjson/ \;; \
3136
fi; \
3237
chmod 0644 /usr/local/share/lua/5.1/cjson/*.lua || true
3338

34-
RUN set -eux; \
35-
if [ ! -f /usr/local/share/lua/5.1/cjson/safe.lua ]; then \
36-
cat > /usr/local/share/lua/5.1/cjson/safe.lua <<'EOF'
39+
RUN cat > /usr/local/share/lua/5.1/cjson/safe.lua <<'EOF'
3740
local cjson = require "cjson"
3841

3942
local _M = {}
@@ -59,33 +62,43 @@ end
5962

6063
return _M
6164
EOF
62-
fi; \
63-
chmod 0644 /usr/local/share/lua/5.1/cjson/safe.lua
6465

66+
RUN chmod 0644 /usr/local/share/lua/5.1/cjson/safe.lua
67+
68+
# ----------------------------
69+
# NDK + lua-nginx-module (dynamic)
70+
# ----------------------------
6571
ARG NDK_V=v0.3.3
6672
ARG LUA_NGX_V=v0.10.27
6773
WORKDIR /usr/src
6874
RUN git clone --branch "${NDK_V}" --single-branch https://github.com/simpl/ngx_devel_kit.git
6975
RUN git clone --branch "${LUA_NGX_V}" --single-branch https://github.com/openresty/lua-nginx-module.git
7076

77+
# ----------------------------
78+
# Build NGINX dynamic modules with --with-compat
79+
# ----------------------------
7180
ARG NGINX_V=1.27.4
7281
RUN wget -O "nginx-${NGINX_V}.tar.gz" "http://nginx.org/download/nginx-${NGINX_V}.tar.gz" \
7382
&& tar zxf "nginx-${NGINX_V}.tar.gz"
7483

7584
WORKDIR /usr/src/nginx-${NGINX_V}
76-
7785
RUN ./configure --with-compat \
7886
--add-dynamic-module=../ngx_devel_kit \
7987
--add-dynamic-module=../lua-nginx-module \
8088
--with-ld-opt="-Wl,-rpath,/usr/local/lib"
8189
RUN make modules -j"$(nproc)"
8290

91+
# ----------------------------
92+
# Smoke test: ensure cjson.safe is loadable by LuaJIT
93+
# ----------------------------
8394
RUN /usr/local/bin/luajit -e 'local x=require("cjson.safe"); assert(x and x.encode and x.decode); print("cjson.safe OK")'
8495

96+
# ----------------------------
97+
# Export artifacts
98+
# ----------------------------
8599
FROM scratch AS out
86100
COPY --from=build /usr/src/nginx-1.27.4/objs/ndk_http_module.so /ndk_http_module.so
87101
COPY --from=build /usr/src/nginx-1.27.4/objs/ngx_http_lua_module.so /ngx_http_lua_module.so
88102
COPY --from=build /usr/local/lib/libluajit-5.1.so.2 /libluajit-5.1.so.2
89103
COPY --from=build /usr/local/lib/lua/5.1/cjson.so /usr/local/lib/lua/5.1/cjson.so
90104
COPY --from=build /usr/local/share/lua/5.1/cjson /usr/local/share/lua/5.1/cjson
91-

0 commit comments

Comments
 (0)