-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.debian
More file actions
91 lines (73 loc) · 2.93 KB
/
Dockerfile.debian
File metadata and controls
91 lines (73 loc) · 2.93 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Multi-stage Dockerfile for redvector - Ultra-performant Redis-compatible server
# Using Debian slim for build, Debian slim for runtime (better compatibility)
# Stage 1: Build dependencies
FROM rust:1.80-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /build
# Copy dependency manifests first for better caching
COPY Cargo.toml ./
COPY command/Cargo.toml ./command/
COPY config/Cargo.toml ./config/
COPY database/Cargo.toml ./database/
COPY networking/Cargo.toml ./networking/
COPY parser/Cargo.toml ./parser/
COPY response/Cargo.toml ./response/
COPY persistence/Cargo.toml ./persistence/
COPY logger/Cargo.toml ./logger/
COPY util/Cargo.toml ./util/
COPY compat/Cargo.toml ./compat/
# Copy Cargo.lock if it exists
COPY Cargo.lock* ./
# Create dummy source files to build dependencies
RUN mkdir -p src command/src config/src database/src networking/src parser/src response/src persistence/src logger/src util/src compat/src && \
echo "fn main() {}" > src/main.rs && \
echo "pub fn dummy() {}" > command/src/lib.rs && \
echo "pub fn dummy() {}" > config/src/lib.rs && \
echo "pub fn dummy() {}" > database/src/lib.rs && \
echo "pub fn dummy() {}" > networking/src/lib.rs && \
echo "pub fn dummy() {}" > parser/src/lib.rs && \
echo "pub fn dummy() {}" > response/src/lib.rs && \
echo "pub fn dummy() {}" > persistence/src/lib.rs && \
echo "pub fn dummy() {}" > logger/src/lib.rs && \
echo "pub fn dummy() {}" > util/src/lib.rs && \
echo "pub fn dummy() {}" > compat/src/lib.rs
# Build dependencies (this layer will be cached)
RUN cargo build --release 2>&1 | grep -v "^ Compiling" || true
# Copy actual source code
COPY . .
# Build the actual application with optimizations
RUN cargo build --release && \
strip /build/target/release/redvector && \
ldd /build/target/release/redvector || true
# Stage 2: Minimal Debian runtime
FROM debian:bookworm-slim
# Install only runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/* && \
groupadd -r -g 1000 redvector && \
useradd -r -u 1000 -g redvector redvector
# Copy the binary from builder
COPY --from=builder /build/target/release/redvector /usr/local/bin/redvector
# Create data directory
RUN mkdir -p /data && chown -R redvector:redvector /data
# Set working directory
WORKDIR /data
# Expose Redis default port
EXPOSE 6379
# Health check using PING command (using sh -c for compatibility)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD sh -c 'echo -e "*1\r\n$$4\r\nPING\r\n" | timeout 1 nc localhost 6379 | grep -q PONG || exit 1'
# Run as non-root user
USER redvector
# Default command
ENTRYPOINT ["/usr/local/bin/redvector"]
# Default arguments (can be overridden)
CMD []