From aee84df665cb89f39d4d0f4c131b2e8acded5870 Mon Sep 17 00:00:00 2001 From: 1iaan <139833683+1iaan@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=B9=E5=99=A8=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 11 +++++++++++ Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++++ config/config.xml | 4 ++-- docker-compose.yml | 16 ++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d45b3df --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.gitignore +data +mem_leak +*.o +kvstore +test-redis/testcase +test-redis/bench +libbpf-bootstrap +ebpf +img diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ad08c68 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +ARG UBUNTU_VERSION=22.04 +ARG APT_MIRROR=mirrors.aliyun.com + +FROM ubuntu:${UBUNTU_VERSION} AS builder + +ARG APT_MIRROR +ENV DEBIAN_FRONTEND=noninteractive + +RUN sed -i "s|http://archive.ubuntu.com/ubuntu/|http://${APT_MIRROR}/ubuntu/|g; s|http://security.ubuntu.com/ubuntu/|http://${APT_MIRROR}/ubuntu/|g" /etc/apt/sources.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + ca-certificates \ + libhiredis-dev \ + liburing-dev \ + libxml2-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY . . + +RUN make kvstore CFLAGS="-g -D_DEFAULT_SOURCE -DJEMALLOC_NO_DEMANGLE" + +FROM ubuntu:${UBUNTU_VERSION} + +ARG APT_MIRROR +ENV DEBIAN_FRONTEND=noninteractive + +RUN sed -i "s|http://archive.ubuntu.com/ubuntu/|http://${APT_MIRROR}/ubuntu/|g; s|http://security.ubuntu.com/ubuntu/|http://${APT_MIRROR}/ubuntu/|g" /etc/apt/sources.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + liburing2 \ + libxml2 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY --from=builder /app/kvstore /app/kvstore + +RUN mkdir -p /app/config /app/data + +EXPOSE 8888 +VOLUME ["/app/data"] + +CMD ["./kvstore"] diff --git a/config/config.xml b/config/config.xml index 606c18b..23f37ac 100644 --- a/config/config.xml +++ b/config/config.xml @@ -1,7 +1,7 @@ - 127.0.0.1 + 0.0.0.0 8888 master @@ -18,7 +18,7 @@ - none + incremental data kvs_oplog.db diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..363ec39 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + kvstore: + build: + context: . + args: + APT_MIRROR: ${APT_MIRROR:-mirrors.aliyun.com} + image: kvstore:single + container_name: kvstore + restart: unless-stopped + security_opt: + - seccomp=unconfined + ports: + - "8888:8888" + volumes: + - ./config/config.xml:/app/config/config.xml:ro + - ./data:/app/data