luarocks 私服搭建&简单使用

luarocks 私服实际上并不算难,核心还是文件,以及元数据,luarocks 提供了相关的命令可以支持

参考处理

需要先基于pack 构建文件,后然使用luarocks-admin 提供的命令生成元数据,对于静态内容的提供我们基于nginx 就可以了

参考构建

  • 编写rocksspec
package = "first"
version = "1.0.0-2"
source = {
   url = "https://github.com/rongfengliang/luarockcs-first-package/releases/download/1.0.0/luarockcs-first-package-1.0.0.tar.gz"
}
description = {
   homepage = "https://cnblogs.com/rongfengliang",
   license = "apache"
}
build = {
   type = "builtin",
   modules = {
      ["resty.dalong"] = "lib/resty/app.lua"
   }
}
  • 构建包
luarocks pack first-1.0.0-2.rockspec 

效果

 

 

  • 生成元数据信息
    基于luarocks-admin 工具
    项目结果
 
├── Dockerfile
├── docker-compose.yaml
├── first-1.0.0-1.src.rock
└── lua-resty-http-0.17.0.beta.1-0.src.rock

元数据命令

luarocks-admin  make_manifest .

效果

 

 


 

 

安装使用

luarocks 包含了一个only-server 参数,可以制定我们的私服,使用此参考就可以使用自己的私服了

 
luarocks install lua-resty-http --only-server http://192.168.31.49:8080/

说明

以上是一个简单的实践,实际上我们也可以直接基于s3 来进行存储,这样好处就很明显了,而且不需要使用服务器了,后边会介绍下

参考资料

https://stackoverflow.com/questions/40845265/how-to-install-luarocks-packages-without-internet?answertab=active#tab-top
https://github.com/luarocks/luarocks/wiki/Creating-a-rock
https://github.com/rongfengliang/luarockcs-first-package

posted on 2022-05-04 11:52  荣锋亮  阅读(316)  评论(0编辑  收藏  举报

导航