https://github.com/rongfengliang/openresty_luarocksmodule-demo
openresty_ with demo luarocks module demo
https://github.com/rongfengliang/openresty_luarocksmodule-demo
docker-compose luarocks oopenresty
Last synced: about 1 month ago
JSON representation
openresty_ with demo luarocks module demo
- Host: GitHub
- URL: https://github.com/rongfengliang/openresty_luarocksmodule-demo
- Owner: rongfengliang
- Created: 2019-01-03T02:15:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-04T02:27:41.000Z (over 7 years ago)
- Last Synced: 2025-10-07T19:56:54.581Z (9 months ago)
- Topics: docker-compose, luarocks, oopenresty
- Language: Lua
- Size: 3.91 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# openresty with simple luarocks demo
## luarocks packages create
* init spec
```code
luarocks-5.1 write_rockspec --lua-version=5.1
```
* add some codes
```code
mkdir -p users
touch users/login.lua
just like below:
function init(name,password)
return name,password
end
return init;
```
* modify spec file info
```code
change name to lua-rocks-app-project-1.0.0-2.rockspec
content like below:
package = "lua-rocks-app-project"
version = "1.0.0-2"
source = {
url = "git://github.com/rongfengliang/luarocks-packagedemo.git"
}
description = {
homepage = "https://github.com/rongfengliang/luarocks-packagedemo.git",
license = "unlicense"
}
dependencies = {
"lua ~> 5.1"
}
build = {
type = "builtin",
modules = {
["users.login"]="users/login.lua"
}
}
```
* publish module
```code
luarocks upload lua-rocks-app-project-1.0.0-2.rockspec --api-key=${api-key}
```
* how to use the package in your project
with openresty for test
```code
mkdir app/app
touch app/app/init.lua
content:
local userslogin = require("users.login")
local json = require("cjson")
function logininfo(name,pass)
local name,pass = userslogin(name,pass)
local loginresult= {
name = name,
pass = pass
}
ngx.say(json.encode(loginresult))
end
return logininfo
openresty call the module
content_by_lua_block {
require("app/init")("dalong","admin");
}
```
## running project
with docker && docker-compose
* dockerfile
add luarocks install module
```code
FROM openresty/openresty:alpine-fat
LABEL author="1141591465@qq.com"
RUN /usr/local/openresty/luajit/bin/luarocks install lua-rocks-app-project
```
* build image
```code
docker-compose build
```
* running
```code
docker-compose up -d
```
* watch result
```code
curl http://localhost:8080/info
```