kore web 项目的单一二进程应用构建
kore 对于开发的web 应用支持基于模块模式的(编译为共享库)以及单一二进制文件(all-in-one)
参考使用
- 核心配置
就是对于通过kodev创建的项目中构建配置添加single_binary=yes
参考配置
# hello build config
# You can switch flavors using: kodev flavor [newflavor]
# Set to yes if you wish to produce a single binary instead
# of a dynamic library. If you set this to yes you must also
# set kore_source together with kore_flavor.
#single_binary=no
#kore_source=/home/joris/src/kore
#kore_flavor=
single_binary=yes
# The flags below are shared between flavors
cflags=-Wall -Wmissing-declarations -Wshadow
cflags=-Wstrict-prototypes -Wmissing-prototypes
cflags=-Wpointer-arith -Wcast-qual -Wsign-compare
cxxflags=-Wall -Wmissing-declarations -Wshadow
cxxflags=-Wpointer-arith -Wcast-qual -Wsign-compare
# Mime types for assets served via the builtin asset_serve_*
#mime_add=txt:text/plain; charset=utf-8
#mime_add=png:image/png
#mime_add=html:text/html; charset=utf-8
dev {
# These flags are added to the shared ones when
# you build the "dev" flavor.
cflags=-g
cxxflags=-g
}
#prod {
# You can specify additional flags here which are only
# included if you build with the "prod" flavor.
#}
- docker 构建
FROM kore/kodev:kodev as base
WORKDIR /hello
COPY . /hello
RUN kodev build
RUN ls -sailh /hello/
# 使用了kore 的基础镜像,其他的会有问题,除非自己完整构建kodev 以及kore 基础镜像,因为单一二进制文件是后台进程
# 所以使用runit 进行进程管理
FROM kore/kore:4.2.3
RUN apk add --no-cache runit
COPY --from=base /hello/hello /app/hello
COPY hello.runit /etc/service/hello/run
RUN chmod +x /etc/service/hello/run
EXPOSE 8888
RUN which runsvdir
ENTRYPOINT ["/sbin/runsvdir", "-P", "/etc/service"]
hello.runit
#!/bin/sh
exec /app/hello
压测
使用loadtest 工具
- 命令
loadtest -n 10000 http://localhost:8888
说明
kore 单一二进制文件的模式是挺方便,但是目前来说它是在构建时将一些公共配置以及运行时配置直接也打包到应用中了
此种方法有好处也有不太方便的地方,就是如果希望重新配置就得重新构建,而且目前基于容器构建需要使用官方的基础
镜像(除非自己重新构建一个)否则会有兼容的问题, 同时似乎应该是可以支持前台进程的,但是在尝试构建的时候木有
成功,完整代码我已经push github 了
参考资料
https://docs.kore.io/4.2.0/applications/building.html
https://github.com/rongfengliang/kore_learning
https://github.com/alexfernandez/loadtest
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-11-29 lavinmq cloudamqp 开源的amqp server
2022-11-29 一些不错的开源内网穿透工具
2022-11-29 一个历史k8s维护碰到的一些网络问题说明
2020-11-29 healthcheck一个不错的 Kubernetes liveness && readiness prob handler 实现
2020-11-29 proxysql proxy 集成golang-mysqlserver
2020-11-29 vernemq 典型的部署模型
2019-11-29 streamsets 官方默认镜像中文支持问题