Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (63 loc) · 1.96 KB
/
Copy pathDockerfile
File metadata and controls
83 lines (63 loc) · 1.96 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
# Multi-stage build for RustDB
FROM rust:1.90-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/*
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY benches ./benches
RUN cargo build --release --bin rustdb
# Profiling image (Linux perf + cargo flamegraph).
# Usage:
# docker build -t rustdb-prof --target profiler .
# docker run --rm --privileged -v "$PWD:/app" -w /app rustdb-prof \
# cargo flamegraph --output profile-out/flame.svg --bin rustdb_load -- <args...>
FROM rust:1.90-slim AS profiler
RUN apt-get update && apt-get install -y \
ca-certificates \
git \
pkg-config \
libssl-dev \
iproute2 \
linux-perf \
&& rm -rf /var/lib/apt/lists/*
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
# Install cargo-flamegraph into the image.
RUN cargo install flamegraph
# Final image — must match builder glibc (rust:1.90-slim uses newer Debian than bookworm).
FROM debian:trixie-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Create unprivileged user
RUN groupadd -r rustdb && useradd -r -g rustdb rustdb
# Create directories
RUN mkdir -p /app/data /app/logs /app/config && \
chown -R rustdb:rustdb /app
# Copy binary
COPY --from=builder /app/target/release/rustdb /usr/local/bin/rustdb
# Copy configuration files
COPY config.toml /app/config/
# Run as rustdb user
USER rustdb
# Working directory
WORKDIR /app
# Exposed ports
EXPOSE 8080 8081
# Environment variables
ENV RUST_LOG=info
ENV RUSTDB_DATA_DIR=/app/data
ENV RUSTDB_LOG_DIR=/app/logs
ENV RUSTDB_CONFIG_DIR=/app/config
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD rustdb --version || exit 1
# Default command
CMD ["rustdb", "--config", "/app/config/config.toml"]