-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (43 loc) · 1.83 KB
/
Dockerfile
File metadata and controls
58 lines (43 loc) · 1.83 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
# Stage 1: Build
FROM rust:latest AS builder
WORKDIR /app
# Copy manifests first for dependency layer caching
COPY Cargo.toml Cargo.lock* ./
COPY crates/server/Cargo.toml crates/server/Cargo.toml
COPY crates/api/Cargo.toml crates/api/Cargo.toml
COPY crates/models/Cargo.toml crates/models/Cargo.toml
COPY crates/web/Cargo.toml crates/web/Cargo.toml
COPY crates/common/Cargo.toml crates/common/Cargo.toml
# Create dummy source files for dependency caching
RUN mkdir -p crates/server/src crates/api/src crates/models/src crates/web/src crates/common/src && \
echo "fn main() {}" > crates/server/src/main.rs && \
echo "" > crates/api/src/lib.rs && \
echo "" > crates/models/src/lib.rs && \
echo "" > crates/web/src/lib.rs && \
echo "" > crates/common/src/lib.rs
# Limit codegen parallelism to reduce peak memory usage on small VPS
ENV SQLX_OFFLINE=true
ENV CARGO_BUILD_JOBS=2
# Build dependencies only (cached layer)
RUN cargo build --release 2>/dev/null || true
# Copy real source code + migrations
COPY crates/ crates/
COPY migrations/ migrations/
# Touch to invalidate cache for source changes
RUN touch crates/server/src/main.rs crates/api/src/lib.rs crates/models/src/lib.rs crates/web/src/lib.rs crates/common/src/lib.rs
# Build the application
RUN cargo build --release
# Stage 2: Runtime (must match builder's glibc — rust:latest uses Trixie)
FROM debian:trixie-slim
RUN apt-get update && \
apt-get install -y ca-certificates curl ffmpeg && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/renzora-server /app/renzora-server
COPY --from=builder /app/migrations /app/migrations
COPY assets/ /app/assets/
COPY docs/ /app/docs/
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
CMD ["/app/renzora-server"]