-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (48 loc) · 1.81 KB
/
Dockerfile
File metadata and controls
64 lines (48 loc) · 1.81 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
# Multi-stage build with Rust 1.90 and Alpine
FROM rust:1.90-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
musl-dev \
protobuf-dev \
protoc
WORKDIR /build
# Copy manifests first for better caching
COPY Cargo.toml Cargo.lock build.rs ./
COPY proto ./proto
# Create dummy main to cache dependencies
RUN mkdir -p src && \
echo "fn main() {}" > src/main.rs && \
cargo build --release --target x86_64-unknown-linux-musl && \
rm -rf src
# Copy real source code
COPY src ./src
# Build for real with static linking
ENV RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-static'
RUN cargo build --release --target x86_64-unknown-linux-musl
# Verify it's static
RUN file /build/target/x86_64-unknown-linux-musl/release/klustrefs-csi-plugin && \
ldd /build/target/x86_64-unknown-linux-musl/release/klustrefs-csi-plugin || true
# Runtime stage - minimal Alpine
FROM alpine:3.22
# OCI image metadata
LABEL org.opencontainers.image.description="KlustreFS CSI plugin for Kubernetes"
LABEL org.opencontainers.image.source="https://github.com/klustrefs/klustre-csi-plugin"
# Install only essential runtime tools
RUN apk add --no-cache \
ca-certificates \
util-linux \
kmod
# Copy static binary from builder
COPY --from=builder \
/build/target/x86_64-unknown-linux-musl/release/klustrefs-csi-plugin \
/usr/local/bin/klustrefs-csi-plugin
# Set permissions and create socket directory
RUN chmod +x /usr/local/bin/klustrefs-csi-plugin && \
mkdir -p /csi
# Add non-root user (optional, CSI needs root for mount)
# RUN addgroup -g 1000 csi && adduser -D -u 1000 -G csi csi
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/usr/local/bin/klustrefs-csi-plugin", "--help"]
ENTRYPOINT ["/usr/local/bin/klustrefs-csi-plugin"]
CMD ["--help"]