forked from PiNetwork/PiRC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dashboard
More file actions
93 lines (75 loc) · 2.69 KB
/
Copy pathDockerfile.dashboard
File metadata and controls
93 lines (75 loc) · 2.69 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
91
92
93
# ============================================================================
# PiRC AI Dashboard - Multi-stage Production Dockerfile
# Optimized for size, speed, and security
# ============================================================================
# ─── STAGE 1: CARGO CACHE & DEPENDENCIES ───
FROM rust:1.76-slim as cargo-cache
WORKDIR /app
RUN rustup default stable && rustup update
# Copy workspace files for dependency caching
COPY Cargo.toml Cargo.lock ./
COPY pirc-dashboard/Cargo.toml ./pirc-dashboard/
COPY pirc-ai-agent/Cargo.toml ./pirc-ai-agent/
COPY pirc-edge-ai/Cargo.toml ./pirc-edge-ai/
COPY pirc-pi-super/Cargo.toml ./pirc-pi-super/
# Pre-download dependencies (cache hit!)
RUN mkdir -p pirc-dashboard/src pirc-ai-agent/src pirc-edge-ai/src pirc-pi-super/src && \
cargo build --release --workspace && \
cargo clean -p pirc-ai-agent pirc-edge-ai pirc-pi-super
# ─── STAGE 2: BUILDER ───
FROM rust:1.76-slim as builder
WORKDIR /app
# Copy cached dependencies
COPY --from=cargo-cache /app/target /app/target
COPY --from=cargo-cache /usr/local/cargo /usr/local/cargo
# Copy source code
COPY pirc-dashboard ./pirc-dashboard
COPY pirc-ai-agent ./pirc-ai-agent
COPY pirc-edge-ai ./pirc-edge-ai
COPY pirc-pi-super ./pirc-pi-super
COPY Cargo.toml Cargo.lock ./
# Build with optimizations
RUN cargo build \
--release \
--package pirc-dashboard \
--features production,dashboard \
--bin pirc-dashboard && \
cargo clean
# ─── STAGE 3: PRODUCTION RUNTIME ───
FROM debian:bookworm-slim as production
# Install minimal runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
fontconfig \
freetype \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r pirc --gid=1001 && \
useradd -r -g pirc --uid=1001 pirc && \
mkdir -p /app /data /models && \
chown -R pirc:pirc /app /data /models
WORKDIR /app
# Copy binary from builder
COPY --from=builder --chown=pirc:pirc /app/target/release/pirc-dashboard ./
# Copy static assets
COPY --chown=pirc:pirc pirc-dashboard/static ./static
COPY --chown=pirc:pirc pirc-dashboard/templates ./templates
# ─── HEALTHCHECK & EXPOSE ───
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# ─── SECURITY & RUNTIME ───
USER pirc
ENV RUST_LOG=info
ENV RUST_BACKTRACE=1
ENV DATABASE_URL=sqlite:///data/dashboard.db
# Pre-warm models directory
VOLUME ["/models", "/data"]
# Graceful shutdown
STOPSIGNAL SIGTERM
# Production entrypoint
CMD ["/app/pirc-dashboard"]