-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (54 loc) · 1.93 KB
/
Dockerfile
File metadata and controls
70 lines (54 loc) · 1.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
# Highly optimized multi-stage build for Allfeat Hub
FROM rust:1.89-slim AS builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Rust toolchain and build tools
RUN rustup target add wasm32-unknown-unknown
RUN cargo install trunk --version 0.21.5
RUN cargo install wasm-bindgen-cli --version 0.2.106
RUN cargo install wasm-opt --locked
WORKDIR /app
# Copy workspace manifests for ALL members
COPY Cargo.toml Cargo.lock ./
COPY apps/hub/backend/Cargo.toml ./apps/hub/backend/
COPY apps/hub/frontend/Cargo.toml ./apps/hub/frontend/
COPY crates/core/Cargo.toml ./crates/core/
COPY crates/ui/Cargo.toml ./crates/ui/
COPY crates/services/Cargo.toml ./crates/services/
# Copy all source code
COPY apps/ ./apps/
COPY crates/ ./crates/
COPY schemas/ ./schemas/
# Build frontend with Trunk
WORKDIR /app/apps/hub/frontend
RUN trunk build --release
# Build backend
WORKDIR /app
RUN cargo build --release --bin allfeat-hub
# ============================================================================
# Runtime stage
# ============================================================================
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy compiled artifacts
COPY --from=builder /app/target/release/allfeat-hub ./allfeat-hub
COPY --from=builder /app/apps/hub/frontend/dist ./apps/hub/frontend/dist
COPY --from=builder /app/apps/hub/frontend/public ./apps/hub/frontend/public
# Create non-root user for security
RUN useradd -r -u 1000 -s /bin/false allfeat && \
chown -R allfeat:allfeat /app
USER allfeat
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
CMD ["./allfeat-hub", "serve", "--port", "3000"]