-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (42 loc) · 2.46 KB
/
Dockerfile
File metadata and controls
55 lines (42 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1: Builder — static binary via musl/Alpine
# ─────────────────────────────────────────────────────────────────────────────
FROM alpine:3.19 AS builder
RUN apk add --no-cache \
build-base cmake git \
linux-headers musl-dev \
g++ make
WORKDIR /src
COPY . .
RUN cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DAPEX_STATIC=ON \
-DCMAKE_CXX_FLAGS="-O3 -march=x86-64" \
&& cmake --build build -j$(nproc)
# Verify the binary is static
RUN file build/kv && ldd build/kv 2>&1 | grep -q "statically linked"
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2: Minimal runtime image (~5 MB)
# ─────────────────────────────────────────────────────────────────────────────
FROM scratch AS runtime
COPY --from=builder /src/build/kv /kv
# WAL directory
VOLUME /data
# KV port (TCP) + Gossip port (UDP, KV port + 1000)
EXPOSE 7001 8001/udp
ENV APEX_ID=1
ENV APEX_PORT=7001
ENV APEX_WAL_DIR=/data
ENV APEX_PEERS=""
ENTRYPOINT ["/kv"]
CMD ["--id", "1", "--port", "7001", "--wal-dir", "/data"]
# ─────────────────────────────────────────────────────────────────────────────
# Convenience: full image with shell for debugging
# ─────────────────────────────────────────────────────────────────────────────
FROM alpine:3.19 AS debug
COPY --from=builder /src/build/kv /usr/local/bin/kv
RUN apk add --no-cache bash curl
VOLUME /data
EXPOSE 7001 8001/udp
ENTRYPOINT ["/usr/local/bin/kv"]
CMD ["--id", "1", "--port", "7001", "--wal-dir", "/data"]