1. lapis docker 镜像制作

因为openresty 新版本一个json 库的问题,我们使用的是 openresty:1.11.2.1 基础镜像

FROM openresty/openresty:1.11.2.1-centos
RUN yum install -y openssl-devel
RUN /usr/local/openresty/luajit/bin/luarocks install luaossl && \
/usr/local/openresty/luajit/bin/luarocks install lapis
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
2. 基本项目
备注:基础镜像可以使用上面构建的,同时可以使已经构建好的

docker pull dalongrong/openrestydemogithub:lapis

lapis 项目结构

├── Dockerfile  // 项目运行的镜像
├── Dockerfile-base // lapis 镜像基于openresty 官方镜像
├── README.md
└── appdemo // 基本lapis 项目
├── app.lua
├── client_body_temp
├── config.lua
├── fastcgi_temp
├── mime.types
├── models.lua
├── nginx.conf
├── nginx.conf.compiled
├── proxy_temp
├── scgi_temp
└── uwsgi_temp
3. 项目代码说明
主要是app.lua 以及config.lua

app.lua

local lapis = require("lapis")
local db = require("lapis.db")
local app = lapis.Application()
local json = require("cjson");
app:get("/", function()
return "Welcome to Lapis " .. require("lapis.version")
end)
app:get("/user", function()
-- local res = db.query("SELECT * FROM userdemo")
-- return json.encode(res)
local res = db.query("SELECT * FROM userdemo")
return { json= res} end)
return app config.lua // 配置数据库访问 local config = require("lapis.config")
config("development", {
mysql = {
host = "mydb",--change to you database url
user = "root",
password = "dalongrong",
database = "userapp"
}
}) Dockerfile FROM mylapis2:latest
WORKDIR /app
COPY appdemo/ /app
EXPOSE 8080
ENTRYPOINT ["lapis"]
CMD ["server", "development"]
4. 运行
docker build -t mylapis .
docker run -d -p 8085:8080 mylapis
5. 参考资料
https://github.com/rongfengliang/openrestydemogithub
http://leafo.net/lapis/reference/actions.html#routes-and-url-patterns/route-precedence
https://github.com/rongfengliang/golangmysql-docker
 
 
 
 

最新文章

  1. jQuery学习过程问题笔记
  2. [转] MemCached 的 stats 命令
  3. 非正规写法获取不到tr,td
  4. CAPI学习心得
  5. JavaScript实用技巧总结
  6. Thrift在Windows及Linux平台下的安装和使用示例
  7. WF4 常用类<第二篇>
  8. 【Android - MD】之TabLayout的使用
  9. jQuery--效果和遍历
  10. 跟着Android学设计模式:代理(proxy)
  11. androidHandler讲解
  12. workday1
  13. js时间戳和日期字符串相互转换
  14. Spring Cloud 服务端注册与客户端调用
  15. hdu1814 Peaceful Commission
  16. Java 跨平台原理
  17. 马昕璐 201771010118《面向对象程序设计(java)》第十五周学习总结
  18. Ubuntu离线安装docker
  19. MySQL之数据导入导出
  20. 博客搬家了,新域名dinphy.wang

热门文章

  1. Spring Cloud实战
  2. Kotlin------类和对象(二)
  3. 解决无法启动mysql服务错误1069
  4. PANDAS 数据合并与重塑(concat篇)
  5. Log4j详细设置说明
  6. Qt5全局热键-QxtGlobalShortcut
  7. centos7&redhat 之 firewalld 详细介绍配置
  8. Mysql加载配置默认路径
  9. ansible配置文件 ansible.cfg的一点说明
  10. APUE学习笔记——6.10 时间与时间例程 time_t