skip to Main Content

I am using this docker-compose to create a Lua supported Nginx:

version: '3.9'
services:
  nginx:
    container_name: local_nginx
    image: fabiocicerchia/nginx-lua

    environment: 
      - REDIS_SERVER=172.26.0.1
    ports: 
      - 8089:80
      - 8053:8053
    volumes: 
      - /home/navid/lua_project/nginx/nginx.conf:/etc/nginx/nginx.conf
      - /home/navid/lua_project/nginx/www:/usr/share/nginx/html
      - /home/navid/lua_project/lib/resty/redis.lua:/usr/local/share/luajit-2.0.4/resty/redis.lua
      - /home/navid/lua_project/lib/resty/kafka:/usr/local/share/lua/5.1/resty/kafka
     
    extra_hosts:
      - host.docker.internal:host-gateway    

and now I need to add cjson library to my container. I try the build method on my host machine but it throws this exception:

lua.h: No such file or directory

And also I added these line to make it on my container:

- /home/navid/lua_project/lib/resty/lua-cjson:/usr/local/share/lua/5.1/resty/cjson
    
        command: 
          - |
            cd /usr/local/share/lua/5.1/resty/cjson
            autoreconf -i -v --force
            ./configure
            make
            make install

but it failed on run phase with this error:

exec: line 38: cd /usr/local/share/lua/5.1/resty/cjson autoreconf -i
-v –force ./configure make make install : not found

is there any straightway to install cjson on my container?

Update:

I finally built and upload cjson.so into my docker container but I am getting this error:

loading module ‘cjson’ from file ‘/usr/local/lib/lua/5.1/cjson.so’:
Error relocating /usr/local/lib/lua/5.1/cjson.so: __snprintf_chk: symbol not found

So is there any other alternative library that has good performance?

2

Answers


  1. It seems you’re trying to use an openresty module with a standard nginx installation, which doesn’t work because they aren’t the same thing. Openresty is nginx + LuaJIT.

    Login or Signup to reply.
  2. This could be the solution to your problem.

    This is a dockerfile that allows having cjson working:

    FROM fabiocicerchia/nginx-lua:1-alpine-compat
    
    RUN apk add gcc musl-dev coreutils 
        && luarocks install lua-cjson
    

    More details on it: https://github.com/fabiocicerchia/nginx-lua/issues/34

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search