Skip to content

Commit 78e460b

Browse files
feat: 添加 Docker 支持并优化 COMMAND 响应
- 新增 Dockerfile 和 .dockerignore 文件,支持 Docker 构建,使用体积较小的alpine静态编译。 - 修改 CMakeLists.txt,添加静态构建选项 - 重构 CommandResponseBuilder,支持 RESP2 和 RESP3 协议。避免顾此失彼。考虑到微软只支持了老版本RESP2,而直接使用RESP3会导致redis-cli在使用COMMAND DOCS之类的指令的时候崩溃,我们直接根据平台来编译支持RESP类型。 - 添加 mimalloc 补丁,修复 Alpine Linux 下的兼容性问题,避免编译时结构体重定义。 - 暂时采用直接退出服务器的方式,后续再慢慢修改
1 parent 13fc694 commit 78e460b

8 files changed

Lines changed: 341 additions & 140 deletions

File tree

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.git
2+
.gitignore
3+
logs/
4+
*.log
5+
temp/
6+
tmp/
7+
build/
8+
out/
9+
cmake-build-debug/
10+
cmake-build-release/
11+
dist/
12+
*.tmp
13+
*.sh
14+
.vs/
15+
*.pyc
16+
__pycache__
17+
.vscode/
18+
.idea/
19+
.cache/
20+
docs/
21+
doc/
22+
*.png
23+
*.jpg
24+
*.json
25+
*.ini

Astra-CacheServer/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
77

88
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
99

10+
# 添加构建选项
11+
option(BUILD_STATIC "Build with static linking" OFF)
12+
option(MI_BUILD_STATIC "Build mimalloc with static linking" OFF)
13+
1014
# 通用的文件
1115
set(SERVER_SOURCE
1216
server.cpp
@@ -34,7 +38,11 @@ endif()
3438

3539
add_lua_support(Astra-CacheServer)
3640
target_compile_definitions(Astra-CacheServer PRIVATE FMT_DISABLE_UTF8=1)
37-
41+
set(MI_BUILD_STATIC ${BUILD_STATIC} CACHE INTERNAL "Inherit static build setting from parent")
42+
target_link_libraries(Astra-CacheServer PRIVATE
43+
$<$<BOOL:${MI_BUILD_STATIC}>:-static>
44+
${CMAKE_THREAD_LIBS_INIT}
45+
)
3846
# target_link_libraries(Astra-CacheServer zenutils)
3947
add_library(Astra-CacheSDK SHARED
4048
sdk/astra_client.cpp

0 commit comments

Comments
 (0)