forked from Snapchat/KeyDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (38 loc) · 1.47 KB
/
Dockerfile
File metadata and controls
53 lines (38 loc) · 1.47 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
# ----------------------
# Builder Stage
# ----------------------
FROM alpine:3.22 AS builder
RUN apk add --no-cache build-base clang llvm lld cmake git jemalloc openssl-dev linux-headers util-linux-dev libunwind-dev curl-dev
WORKDIR /keydb
COPY . .
RUN make -j$(nproc) && make install
# ----------------------
# Final Stage
# ----------------------
FROM alpine:3.22
# Install runtime dependencies
RUN apk add --no-cache jemalloc openssl su-exec libuuid libcurl libunwind
# Create keydb user and group
RUN addgroup -S keydb && adduser -S keydb -G keydb
# Copy binaries from builder
COPY --from=builder /usr/local/bin/keydb-server /usr/local/bin/keydb-server
COPY --from=builder /usr/local/bin/keydb-cli /usr/local/bin/keydb-cli
# Add default config (can be overridden by volume)
COPY keydb.conf /etc/keydb/keydb.conf
# Set Kubernetes-friendly defaults
RUN sed -i 's/^bind 127.0.0.1 -::1$/bind 0.0.0.0/' /etc/keydb/keydb.conf && \
sed -i 's/^protected-mode yes$/protected-mode no/' /etc/keydb/keydb.conf
# Entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create data directory and set ownership
RUN mkdir -p /data && chown keydb:keydb /data
# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD keydb-cli ping || exit 1
VOLUME /data
WORKDIR /data
EXPOSE 6379
# Use exec form for proper signal handling
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["keydb-server", "/etc/keydb/keydb.conf"]