Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about LUA_PATH #203

Closed
kwypchlo opened this issue Apr 4, 2022 · 2 comments
Closed

Question about LUA_PATH #203

kwypchlo opened this issue Apr 4, 2022 · 2 comments

Comments

@kwypchlo
Copy link

kwypchlo commented Apr 4, 2022

Hey! Not strictly an issue but I've been looking at the LUA_PATH in docker images and it's set like this.

ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua"

I noticed that /usr/local/openresty/site/lualib is empty - would it be a good practice if I mounted my libs directory there?
Currently I'm adding a custom path in nginx.conf lua_package_path "/etc/nginx/libs/?.lua;;"; and mount my libs to /etc/nginx/libs and it works too but I'd much rather like to drop the custom path and use built in if that's what it was created for.

Best, Karol

@neomantra
Copy link
Member

One thing I just noticed in looking at this... the "build-from-source" flavors include that directive, but the "upstream" flavors do not. I did some archaeology to see why this is... and it's from #53 where I added it for LuaRocks. So only images that use LuaRocks has that built-in. You can try openresty/openresty:focal

$ docker run -it --rm --entrypoint=/bin/bash openresty/openresty:bullseye  -c 'echo $LUA_PATH'

$ docker run -it --rm --entrypoint=/bin/bash openresty/openresty:focal  -c 'echo $LUA_PATH'
/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua

Other than that, I think it should work fine if you use an image with that... here's a test with resty:

$ echo 'print("hello world")' > hellotest.lua

$ docker run -it -v $(pwd):/usr/local/openresty/site/lualib --rm --entrypoint=/usr/local/openresty/bin/resty openresty/openresty:focal -e 'require "hellotest"'
hello world

Related also is #186

@kwypchlo
Copy link
Author

kwypchlo commented Apr 6, 2022

Thanks for the response. The question was whether you had any intention for that directory to hold anything system specific now or in future or was it included for developer usage so from your answer I assume the latter. I've tested it myself and worked like a charm 👍 saved me one line of updating lua_package_path in conf file haha 🎉

@kwypchlo kwypchlo closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants